From 0e561a84cf3c7692d566f64b0b6ee1be7301055a Mon Sep 17 00:00:00 2001 From: Olli Pettay Date: Wed, 28 Jun 2017 22:38:53 +0300 Subject: [PATCH] Bug 1371242, try to run CC slices more likely during idle periods, r=mccr8 --HG-- extra : rebase_source : 9727cb14deafe3b92139646074ea201126579c1f --- 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 ea7331b59fcf..960ebf75bde2 100644 --- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -60,6 +60,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" @@ -125,12 +126,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 @@ -1741,7 +1742,10 @@ nsJSContext::RunCycleCollectorSlice(TimeStamp aDeadline) } } - nsCycleCollector_collectSlice(budget); + nsCycleCollector_collectSlice(budget, + aDeadline.IsNull() || + (aDeadline - TimeStamp::Now()).ToMilliseconds() < + kICCSliceBudget); gCCStats.FinishCycleCollectionSlice(); } @@ -2103,6 +2107,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 {