Bug 1367905 - Try to run GC/CC slices, including forgetSkippable, during idle time, tweaks to keep reftest memory usage lower, r=mccr8
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Sat, 10 Jun 2017 02:41:06 +0300
changeset 411492 d3eb944e22e1df2a3461ef7a80c23639e86c62da
parent 411491 22c8d6540061dc3d016bb25568b477f72562accb
child 411493 aee83eca587fdd51b9b29830eee0905606b25fa9
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1367905
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1367905 - Try to run GC/CC slices, including forgetSkippable, during idle time, tweaks to keep reftest memory usage lower, r=mccr8
dom/base/nsJSEnvironment.cpp
layout/tools/reftest/reftest-content.js
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -235,16 +235,20 @@ typedef bool (*CollectorRunnerCallback) 
 // Repeating callback runner for CC and GC.
 class CollectorRunner final : public IdleRunnable
 {
 public:
   static already_AddRefed<CollectorRunner>
   Create(CollectorRunnerCallback aCallback, uint32_t aDelay,
          int64_t aBudget, bool aRepeating, void* aData = nullptr)
   {
+    if (sShuttingDown) {
+      return nullptr;
+    }
+
     RefPtr<CollectorRunner> runner =
       new CollectorRunner(aCallback, aDelay, aBudget, aRepeating, aData);
     runner->Schedule(false); // Initial scheduling shouldn't use idle dispatch.
     return runner.forget();
   }
 
   NS_IMETHOD Run() override
   {
@@ -1916,17 +1920,20 @@ nsJSContext::EndCycleCollectionCallback(
 }
 
 // static
 bool
 InterSliceGCRunnerFired(TimeStamp aDeadline, void* aData)
 {
   nsJSContext::KillInterSliceGCRunner();
   MOZ_ASSERT(sActiveIntersliceGCBudget > 0);
-  int64_t budget = sActiveIntersliceGCBudget;
+  // We use longer budgets when timer runs since that means
+  // there hasn't been idle time recently and we may have significant amount
+  // garbage to collect.
+  int64_t budget = sActiveIntersliceGCBudget * 2;
   if (!aDeadline.IsNull()) {
     budget = int64_t((aDeadline - TimeStamp::Now()).ToMilliseconds());
   }
 
   uintptr_t reason = reinterpret_cast<uintptr_t>(aData);
   nsJSContext::GarbageCollectNow(aData ?
                                    static_cast<JS::gcreason::Reason>(reason) :
                                    JS::gcreason::INTER_SLICE_GC,
--- a/layout/tools/reftest/reftest-content.js
+++ b/layout/tools/reftest/reftest-content.js
@@ -36,17 +36,16 @@ var gHaveCanvasSnapshot = false;
 var gExplicitPendingPaintCount = 0;
 var gExplicitPendingPaintsCompleteHook;
 var gCurrentURL;
 var gCurrentTestType;
 var gTimeoutHook = null;
 var gFailureTimeout = null;
 var gFailureReason;
 var gAssertionCount = 0;
-var gTestCount = 0;
 
 var gDebug;
 var gVerbose = false;
 
 var gCurrentTestStartTime;
 var gClearingForAssertionCheck = false;
 
 const TYPE_LOAD = 'load';  // test without a reference (just test that it does
@@ -138,21 +137,17 @@ function SetFailureTimeout(cb, timeout)
   gFailureTimeout = setTimeout(wrapper, timeout);
 }
 
 function StartTestURI(type, uri, timeout)
 {
     // The GC is only able to clean up compartments after the CC runs. Since
     // the JS ref tests disable the normal browser chrome and do not otherwise
     // create substatial DOM garbage, the CC tends not to run enough normally.
-    ++gTestCount;
-    if (gTestCount % 500 == 0) {
-        CU.forceGC();
-        CU.forceCC();
-    }
+    windowUtils().runNextCollectorTimer();
 
     // Reset gExplicitPendingPaintCount in case there was a timeout or
     // the count is out of sync for some other reason
     if (gExplicitPendingPaintCount != 0) {
         LogWarning("Resetting gExplicitPendingPaintCount to zero (currently " +
                    gExplicitPendingPaintCount + "\n");
         gExplicitPendingPaintCount = 0;
     }