Bug 1544866 - Make InterSliceGCRunnerFired to return false in case the full budget wasn't used. r=sfink
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Tue, 16 Apr 2019 19:59:30 +0000
changeset 469779 b674f733df77
parent 469778 ebcc8dd9c2bc
child 469780 bdc09ee18819
push id35882
push usercbrindusan@mozilla.com
push dateWed, 17 Apr 2019 15:54:01 +0000
treeherdermozilla-central@37185c0ae520 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs1544866
milestone68.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 1544866 - Make InterSliceGCRunnerFired to return false in case the full budget wasn't used. r=sfink Differential Revision: https://phabricator.services.mozilla.com/D27756
dom/base/nsJSEnvironment.cpp
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -1763,17 +1763,23 @@ bool InterSliceGCRunnerFired(TimeStamp a
         idleDuration = sliceDuration;
       }
     }
 
     uint32_t percent =
         uint32_t(idleDuration.ToSeconds() / duration.ToSeconds() * 100);
     Telemetry::Accumulate(Telemetry::GC_SLICE_DURING_IDLE, percent);
   }
-  return true;
+
+  // If we didn't use the whole budget, we're past the foreground sweeping slice
+  // and will need to wait for the background tasks to finish, or we're at the
+  // last slice. Return value on the latter case doesn't matter, and on the
+  // former we want to wait a bit before polling again.
+  // Returning false makes IdleTaskRunner postpone the next call a bit.
+  return int64_t(sliceDuration.ToMilliseconds()) >= budget;
 }
 
 // static
 void GCTimerFired(nsITimer* aTimer, void* aClosure) {
   nsJSContext::KillGCTimer();
   if (sShuttingDown) {
     nsJSContext::KillInterSliceGCRunner();
     return;