Add a separate aggressive GC mode

This commit is contained in:
Alexander Shabalin
2021-06-18 12:03:02 +00:00
committed by Space
parent 1cfe1c41ef
commit e240b8a8ee
10 changed files with 41 additions and 4 deletions
@@ -109,6 +109,14 @@ void gc::SameThreadMarkAndSweep::ThreadData::SafePointRegular(size_t weight) noe
safePointsCounter_ += weight;
}
gc::SameThreadMarkAndSweep::SameThreadMarkAndSweep() noexcept {
if (Kotlin_getGcAggressive()) {
// TODO: Make it even more aggressive and run on a subset of backend.native tests.
threshold_ = 1000;
allocationThresholdBytes_ = 10000;
}
}
mm::ObjectFactory<gc::SameThreadMarkAndSweep>::FinalizerQueue gc::SameThreadMarkAndSweep::PerformFullGC() noexcept {
bool didSuspend = mm::SuspendThreads();
if (!didSuspend) {
@@ -63,7 +63,7 @@ public:
size_t safePointsCounter_ = 0;
};
SameThreadMarkAndSweep() noexcept {}
SameThreadMarkAndSweep() noexcept;
~SameThreadMarkAndSweep() = default;
void SetThreshold(size_t value) noexcept { threshold_ = value; }
@@ -78,8 +78,8 @@ public:
private:
mm::ObjectFactory<SameThreadMarkAndSweep>::FinalizerQueue PerformFullGC() noexcept;
size_t threshold_ = 1000;
size_t allocationThresholdBytes_ = 10000;
size_t threshold_ = 100000; // Roughly 1 safepoint per 10ms (on a subset of examples on one particular machine).
size_t allocationThresholdBytes_ = 10 * 1024 * 1024; // 10MiB by default.
bool autoTune_ = false;
};
@@ -31,13 +31,18 @@ struct InitNode {
InitNode* next;
};
// This global is overriden by the compiler.
// These globals are overriden by the compiler.
RUNTIME_WEAK DestroyRuntimeMode Kotlin_destroyRuntimeMode = DESTROY_RUNTIME_ON_SHUTDOWN;
RUNTIME_WEAK KInt Kotlin_gcAggressive = 0;
DestroyRuntimeMode Kotlin_getDestroyRuntimeMode() {
return Kotlin_destroyRuntimeMode;
}
bool Kotlin_getGcAggressive() {
return Kotlin_gcAggressive != 0;
}
namespace {
InitNode* initHeadNode = nullptr;
@@ -32,6 +32,7 @@ enum DestroyRuntimeMode {
};
DestroyRuntimeMode Kotlin_getDestroyRuntimeMode();
bool Kotlin_getGcAggressive();
// For experimental MM, if runtime gets initialized, it will be in the native state after this.
RUNTIME_NOTHROW void Kotlin_initRuntimeIfNeeded();