Bug 1158558 - Part 1: Expand time logging in BeginCollection. r=smaug, a=sledru
authorAndrew McCreight <continuation@gmail.com>
Fri, 15 May 2015 10:33:09 -0700
changeset 262308 daf478785c62acb93c126d1fe111451b5d14ca1a
parent 262307 26f06cf226703ffce12890f83210d60df80ca821
child 262309 feaee5986ce1665358b2ab96372c214e6f1d4b03
push id8045
push userryanvm@gmail.com
push dateMon, 25 May 2015 19:02:03 +0000
treeherdermozilla-aurora@3caa82a8604d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, sledru
bugs1158558
milestone40.0a2
Bug 1158558 - Part 1: Expand time logging in BeginCollection. r=smaug, a=sledru
xpcom/base/nsCycleCollector.cpp
--- a/xpcom/base/nsCycleCollector.cpp
+++ b/xpcom/base/nsCycleCollector.cpp
@@ -1320,17 +1320,17 @@ public:
                            size_t* aWeakMapsSize,
                            size_t* aPurpleBufferSize) const;
 
   JSPurpleBuffer* GetJSPurpleBuffer();
 private:
   void CheckThreadSafety();
   void ShutdownCollect();
 
-  void FixGrayBits(bool aForceGC);
+  void FixGrayBits(bool aForceGC, TimeLog& aTimeLog);
   bool ShouldMergeZones(ccType aCCType);
 
   void BeginCollection(ccType aCCType, nsICycleCollectorListener* aManualListener);
   void MarkRoots(SliceBudget& aBudget);
   void ScanRoots(bool aFullySynchGraphBuild);
   void ScanIncrementalRoots();
   void ScanWhiteNodes(bool aFullySynchGraphBuild);
   void ScanBlackNodes();
@@ -3479,40 +3479,40 @@ nsCycleCollector::CheckThreadSafety()
 
 // The cycle collector uses the mark bitmap to discover what JS objects
 // were reachable only from XPConnect roots that might participate in
 // cycles. We ask the JS runtime whether we need to force a GC before
 // this CC. It returns true on startup (before the mark bits have been set),
 // and also when UnmarkGray has run out of stack.  We also force GCs on shut
 // down to collect cycles involving both DOM and JS.
 void
-nsCycleCollector::FixGrayBits(bool aForceGC)
+nsCycleCollector::FixGrayBits(bool aForceGC, TimeLog& aTimeLog)
 {
   CheckThreadSafety();
 
   if (!mJSRuntime) {
     return;
   }
 
   if (!aForceGC) {
     mJSRuntime->FixWeakMappingGrayBits();
+    aTimeLog.Checkpoint("FixWeakMappingGrayBits");
 
     bool needGC = !mJSRuntime->AreGCGrayBitsValid();
     // Only do a telemetry ping for non-shutdown CCs.
     CC_TELEMETRY(_NEED_GC, needGC);
     if (!needGC) {
       return;
     }
     mResults.mForcedGC = true;
   }
 
-  TimeLog timeLog;
   mJSRuntime->GarbageCollect(aForceGC ? JS::gcreason::SHUTDOWN_CC :
                                         JS::gcreason::CC_FORCED);
-  timeLog.Checkpoint("GC()");
+  aTimeLog.Checkpoint("FixGrayBits GC");
 }
 
 void
 nsCycleCollector::CleanupAfterCollection()
 {
   TimeLog timeLog;
   MOZ_ASSERT(mIncrementalPhase == CleanupPhase);
   mGraph.Clear();
@@ -3763,33 +3763,35 @@ nsCycleCollector::BeginCollection(ccType
   }
 
   bool forceGC = isShutdown;
   if (!forceGC && mListener) {
     // On a WantAllTraces CC, force a synchronous global GC to prevent
     // hijinks from ForgetSkippable and compartmental GCs.
     mListener->GetWantAllTraces(&forceGC);
   }
-  FixGrayBits(forceGC);
+  FixGrayBits(forceGC, timeLog);
 
   FreeSnowWhite(true);
+  timeLog.Checkpoint("BeginCollection FreeSnowWhite");
 
   if (mListener && NS_FAILED(mListener->Begin())) {
     mListener = nullptr;
   }
 
   // Set up the data structures for building the graph.
   mGraph.Init();
   mResults.Init();
   bool mergeZones = ShouldMergeZones(aCCType);
   mResults.mMergedZones = mergeZones;
 
   MOZ_ASSERT(!mBuilder, "Forgot to clear mBuilder");
   mBuilder = new CCGraphBuilder(mGraph, mResults, mJSRuntime, mListener,
                                 mergeZones);
+  timeLog.Checkpoint("BeginCollection prepare graph builder");
 
   if (mJSRuntime) {
     mJSRuntime->TraverseRoots(*mBuilder);
     timeLog.Checkpoint("mJSRuntime->TraverseRoots()");
   }
 
   AutoRestore<bool> ar(mScanInProgress);
   MOZ_ASSERT(!mScanInProgress);