SmartGC add a delay 2s mechanism for cold start

Description:SmartGC add a delay 2s mechanism for cold start
Issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I8EMEE

Signed-off-by: dingwen <dingwen6@huawei.com>
Change-Id: Ic868b5d549d05c36100dc7c9645f285e0d44222e
This commit is contained in:
dingwen 2023-11-07 19:19:23 +08:00
parent eb88361a84
commit 9ca424246a
3 changed files with 7 additions and 1 deletions

View File

@ -147,6 +147,7 @@ void EcmaVM::PostFork()
heap_->EnableParallelGC();
#ifdef ENABLE_POSTFORK_FORCEEXPAND
heap_->NotifyPostFork();
heap_->NotifyFinishColdStartSoon();
#endif
}

View File

@ -1142,6 +1142,7 @@ void Heap::NotifyFinishColdStart(bool isMainThread)
GetNewSpace()->SetOverShootSize(std::max(overshootSize, (int64_t)0));
GetNewSpace()->SetWaterLineWithoutGC();
onStartupEvent_ = false;
LOG_GC(INFO) << "SmartGC: exit app cold start";
}
if (isMainThread && CheckCanTriggerConcurrentMarking()) {
@ -1165,6 +1166,7 @@ void Heap::NotifyHighSensitive(bool isStart)
{
onHighSensitiveEvent_ = isStart;
if (!onHighSensitiveEvent_ && !onStartupEvent_) {
LOG_GC(DEBUG) << "SmartGC: exit high sensitive scene";
// set overshoot size to increase gc threashold larger 8MB than current heap size.
int64_t semiRemainSize =
static_cast<int64_t>(GetNewSpace()->GetInitialCapacity() - GetNewSpace()->GetCommittedSize());
@ -1177,7 +1179,9 @@ void Heap::NotifyHighSensitive(bool isStart)
TryTriggerIncrementalMarking();
TryTriggerIdleCollection();
TryTriggerConcurrentMarking();
return;
}
LOG_GC(DEBUG) << "SmartGC: enter high sensitive scene";
}
bool Heap::NeedStopCollection()
@ -1190,7 +1194,7 @@ bool Heap::NeedStopCollection()
ecmaVm_->GetEcmaParamConfiguration().GetOldSpaceOvershootSize()) {
return true;
}
LOG_GC(INFO) << "SmartGC: force expand will cause OOM, have to trigger gc";
GetNewSpace()->SetOverShootSize(
GetNewSpace()->GetCommittedSize() - GetNewSpace()->GetInitialCapacity() +
ecmaVm_->GetEcmaParamConfiguration().GetOldSpaceOvershootSize());

View File

@ -233,6 +233,7 @@ public:
{
LockHolder holder(finishColdStartMutex_);
onStartupEvent_ = true;
LOG_GC(INFO) << "SmartGC: enter app cold start";
}
/*