From b12cefe84158b5a0ea04467ac4dd739ee564dcca Mon Sep 17 00:00:00 2001 From: win7-7 Date: Sat, 27 Apr 2024 16:02:38 +0300 Subject: [PATCH] 1371242 - Investigate if CC slices could use idle periods more likely 1371242, try to run CC slices more likely during idle periods. --- dom/base/nsJSEnvironment.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp index 7da1a23ac4..ea352718fb 100644 --- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -54,6 +54,7 @@ #include "mozilla/StaticPtr.h" #include "mozilla/dom/DOMException.h" #include "mozilla/dom/DOMExceptionBinding.h" +#include "mozilla/dom/Element.h" #include "mozilla/dom/ErrorEvent.h" #include "mozilla/dom/ScriptSettings.h" #include "nsAXPCNativeCallContext.h" @@ -119,12 +120,12 @@ const size_t gStackSize = 8192; static const int64_t kForgetSkippableSliceDuration = 2; // Maximum amount of time that should elapse between incremental CC slices -static const int64_t kICCIntersliceDelay = 32; // ms +static const int64_t kICCIntersliceDelay = 64; // ms // Time budget for an incremental CC slice when using timer to run it. -static const int64_t kICCSliceBudget = 5; // ms +static const int64_t kICCSliceBudget = 3; // ms // Minimum budget for an incremental CC slice when using idle time to run it. -static const int64_t kIdleICCSliceBudget = 3; // ms +static const int64_t kIdleICCSliceBudget = 2; // ms // Maximum total duration for an ICC static const uint32_t kMaxICCDuration = 2000; // ms @@ -1585,7 +1586,10 @@ nsJSContext::RunCycleCollectorSlice(TimeStamp aDeadline) } } - nsCycleCollector_collectSlice(budget); + nsCycleCollector_collectSlice(budget, + aDeadline.IsNull() || + (aDeadline - TimeStamp::Now()).ToMilliseconds() < + kICCSliceBudget); gCCStats.FinishCycleCollectionSlice(); } @@ -1919,6 +1923,11 @@ CCRunnerFired(TimeStamp aDeadline, void* aData) if (ShouldTriggerCC(nsCycleCollector_suspectedCount())) { // Our efforts to avoid a CC have failed, so we return to let the // timer fire once more to trigger a CC. + + // Clear content unbinder before the first CC slice. + Element::ClearContentUnbinder(); + // And trigger deferred deletion too. + nsCycleCollector_doDeferredDeletion(); return didDoWork; } } else {