Bug 1371224 - Add markers for forgetSkippable and CC slices, r=mccr8,mstange
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Sat, 10 Jun 2017 03:16:25 +0300
changeset 411493 aee83eca587fdd51b9b29830eee0905606b25fa9
parent 411492 d3eb944e22e1df2a3461ef7a80c23639e86c62da
child 411494 6fdd4f87cc0ea91ee036b38fa1ce58f7eaea88ea
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, mstange
bugs1371224
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 1371224 - Add markers for forgetSkippable and CC slices, r=mccr8,mstange
dom/base/nsJSEnvironment.cpp
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -1416,18 +1416,21 @@ FinishAnyIncrementalGC()
   if (sCCLockedOut) {
     // We're in the middle of an incremental GC, so finish it.
     JS::PrepareForIncrementalGC(sContext);
     JS::FinishIncrementalGC(sContext, JS::gcreason::CC_FORCED);
   }
 }
 
 static void
-FireForgetSkippable(uint32_t aSuspected, bool aRemoveChildless)
+FireForgetSkippable(uint32_t aSuspected, bool aRemoveChildless,
+                    TimeStamp aDeadline)
 {
+  GeckoProfilerTracingRAII
+    tracer("CC", aDeadline.IsNull() ? "ForgetSkippable" : "IdleForgetSkippable");
   PRTime startTime = PR_Now();
   FinishAnyIncrementalGC();
   bool earlyForgetSkippable =
     sCleanupsSinceLastGC < NS_MAJOR_FORGET_SKIPPABLE_CALLS;
   nsCycleCollector_forgetSkippable(aRemoveChildless, earlyForgetSkippable);
   sPreviousSuspectedCount = nsCycleCollector_suspectedCount();
   ++sCleanupsSinceLastGC;
   PRTime delta = PR_Now() - startTime;
@@ -1590,22 +1593,22 @@ void
 CycleCollectorStats::RunForgetSkippable()
 {
   // Run forgetSkippable synchronously to reduce the size of the CC graph. This
   // is particularly useful if we recently finished a GC.
   if (mExtraForgetSkippableCalls >= 0) {
     TimeStamp beginForgetSkippable = TimeStamp::Now();
     bool ranSyncForgetSkippable = false;
     while (sCleanupsSinceLastGC < NS_MAJOR_FORGET_SKIPPABLE_CALLS) {
-      FireForgetSkippable(nsCycleCollector_suspectedCount(), false);
+      FireForgetSkippable(nsCycleCollector_suspectedCount(), false, TimeStamp());
       ranSyncForgetSkippable = true;
     }
 
     for (int32_t i = 0; i < mExtraForgetSkippableCalls; ++i) {
-      FireForgetSkippable(nsCycleCollector_suspectedCount(), false);
+      FireForgetSkippable(nsCycleCollector_suspectedCount(), false, TimeStamp());
       ranSyncForgetSkippable = true;
     }
 
     if (ranSyncForgetSkippable) {
       mMaxSkippableDuration =
         std::max(mMaxSkippableDuration, TimeUntilNow(beginForgetSkippable));
       mRanSyncForgetSkippable = true;
     }
@@ -1634,16 +1637,19 @@ nsJSContext::CycleCollectNow(nsICycleCol
 //static
 void
 nsJSContext::RunCycleCollectorSlice(TimeStamp aDeadline)
 {
   if (!NS_IsMainThread()) {
     return;
   }
 
+  GeckoProfilerTracingRAII
+    tracer("CC", aDeadline.IsNull() ? "CCSlice" : "IdleCCSlice");
+
   PROFILER_LABEL("nsJSContext", "RunCycleCollectorSlice",
     js::ProfileEntry::Category::CC);
 
   gCCStats.PrepareForCycleCollectionSlice();
 
   // Decide how long we want to budget for this slice. By default,
   // use an unlimited budget.
   js::SliceBudget budget = js::SliceBudget::unlimited();
@@ -2011,17 +2017,17 @@ CCRunnerFired(TimeStamp aDeadline, void*
   // late timer fire, we decide if we are going to have a second and final
   // late timer fire, where we may begin to run the CC. Should run at least one
   // early timer fire to allow cleanup before the CC.
   int32_t numEarlyTimerFires = std::max((int32_t)ccDelay / NS_CC_SKIPPABLE_DELAY - 2, 1);
   bool isLateTimerFire = sCCRunnerFireCount > numEarlyTimerFires;
   uint32_t suspected = nsCycleCollector_suspectedCount();
   if (isLateTimerFire && ShouldTriggerCC(suspected)) {
     if (sCCRunnerFireCount == numEarlyTimerFires + 1) {
-      FireForgetSkippable(suspected, true);
+      FireForgetSkippable(suspected, true, aDeadline);
       didDoWork = true;
       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.
         return didDoWork;
       }
     } else {
       // We are in the final timer fire and still meet the conditions for
@@ -2029,17 +2035,17 @@ CCRunnerFired(TimeStamp aDeadline, void*
       // any because that will allow us to include the GC time in the CC pause.
       nsJSContext::RunCycleCollectorSlice(aDeadline);
       didDoWork = true;
     }
   } else if (((sPreviousSuspectedCount + 100) <= suspected) ||
              (sCleanupsSinceLastGC < NS_MAJOR_FORGET_SKIPPABLE_CALLS)) {
       // Only do a forget skippable if there are more than a few new objects
       // or we're doing the initial forget skippables.
-      FireForgetSkippable(suspected, false);
+      FireForgetSkippable(suspected, false, aDeadline);
       didDoWork = true;
   }
 
   if (isLateTimerFire) {
     ccDelay = NS_CC_DELAY;
 
     // We have either just run the CC or decided we don't want to run the CC
     // next time, so kill the timer.