Bug 663920 - add telemetry for num of RCed and GCed nodes, and num collected. r=bent
authorAndrew McCreight <amccreight@mozilla.com>
Fri, 10 Jun 2011 13:33:06 -0700
changeset 72735 f89d4b284590010c324d0f476fdb199ae943c81f
parent 72734 e5de7146ac1932221df7097e1f50af0c3b9fdc1d
child 72736 ae8e81569712507b6df64ee664a84232dc883be6
push id159
push usereakhgari@mozilla.com
push dateTue, 16 Aug 2011 17:53:11 +0000
treeherdermozilla-beta@8786e3e49240 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbent
bugs663920
milestone7.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 663920 - add telemetry for num of RCed and GCed nodes, and num collected. r=bent
toolkit/components/telemetry/TelemetryHistograms.h
xpcom/base/nsCycleCollector.cpp
--- a/toolkit/components/telemetry/TelemetryHistograms.h
+++ b/toolkit/components/telemetry/TelemetryHistograms.h
@@ -40,16 +40,19 @@
  * This file lists Telemetry histograms collected by Firefox.  The format is
  *
  *    HISTOGRAM(id, minium, maximum, bucket count, histogram kind,
  *              human-readable description for about:telemetry)
  *
  */
 
 HISTOGRAM(CYCLE_COLLECTOR, 1, 10000, 50, EXPONENTIAL, "Time spent on one cycle collection (ms)")
+HISTOGRAM(CYCLE_COLLECTOR_VISITED_REF_COUNTED, 1, 300000, 50, EXPONENTIAL, "Number of ref counted objects visited by the cycle collector")
+HISTOGRAM(CYCLE_COLLECTOR_VISITED_GCED, 1, 300000, 50, EXPONENTIAL, "Number of JS objects visited by the cycle collector")
+HISTOGRAM(CYCLE_COLLECTOR_COLLECTED, 1, 100000, 50, EXPONENTIAL, "Number of objects collected by the cycle collector")
 HISTOGRAM(TELEMETRY_PING, 1, 3000, 10, EXPONENTIAL, "Time taken to submit telemetry info (ms)")
 HISTOGRAM(TELEMETRY_SUCCESS, 0, 1, 2, BOOLEAN,  "Successful telemetry submission")
 HISTOGRAM(MEMORY_JS_GC_HEAP, 1024, 512 * 1024, 10, EXPONENTIAL, "Memory used by the garbage-collected JavaScript heap (KB)")
 HISTOGRAM(MEMORY_RESIDENT, 32 * 1024, 1024 * 1024, 10, EXPONENTIAL, "Resident memory size (KB)")
 HISTOGRAM(MEMORY_LAYOUT_ALL, 1024, 64 * 1024, 10, EXPONENTIAL, "Memory used by layout (KB)")
 #if defined(XP_WIN)
 HISTOGRAM(EARLY_GLUESTARTUP_READ_OPS, 1, 100, 12, LINEAR, "ProcessIoCounters.ReadOperationCount before glue startup")
 HISTOGRAM(EARLY_GLUESTARTUP_READ_TRANSFER, 1, 50 * 1024, 12, EXPONENTIAL, "ProcessIoCounters.ReadTransferCount before glue startup (KB)")
--- a/xpcom/base/nsCycleCollector.cpp
+++ b/xpcom/base/nsCycleCollector.cpp
@@ -1014,16 +1014,20 @@ struct nsCycleCollector
 
     GCGraph mGraph;
 
     nsCycleCollectorParams mParams;
 
     nsTPtrArray<PtrInfo> *mWhiteNodes;
     PRUint32 mWhiteNodeCount;
 
+    // mVisitedRefCounted and mVisitedGCed are only used for telemetry
+    PRUint32 mVisitedRefCounted;
+    PRUint32 mVisitedGCed;
+
     nsPurpleBuffer mPurpleBuf;
 
     void RegisterRuntime(PRUint32 langID, 
                          nsCycleCollectionLanguageRuntime *rt);
     nsCycleCollectionLanguageRuntime * GetRuntime(PRUint32 langID);
     void ForgetRuntime(PRUint32 langID);
 
     void SelectPurple(GCGraphBuilder &builder);
@@ -1618,24 +1622,26 @@ GCGraphBuilder::NoteRoot(PRUint32 langID
 NS_IMETHODIMP_(void)
 GCGraphBuilder::DescribeRefCountedNode(nsrefcnt refCount, size_t objSz,
                                        const char *objName)
 {
     if (refCount == 0)
         Fault("zero refcount", mCurrPi);
     if (refCount == PR_UINT32_MAX)
         Fault("overflowing refcount", mCurrPi);
+    sCollector->mVisitedRefCounted++;
     DescribeNode(refCount, objSz, objName);
 }
 
 NS_IMETHODIMP_(void)
 GCGraphBuilder::DescribeGCedNode(PRBool isMarked, size_t objSz,
                                  const char *objName)
 {
     PRUint32 refCount = isMarked ? PR_UINT32_MAX : 0;
+    sCollector->mVisitedGCed++;
     DescribeNode(refCount, objSz, objName);
 }
 
 NS_IMETHODIMP_(void)
 GCGraphBuilder::NoteXPCOMChild(nsISupports *child) 
 {
     nsCString edgeName;
     if (WantDebugInfo()) {
@@ -2190,16 +2196,18 @@ InitMemHook(void)
 ////////////////////////////////////////////////////////////////////////
 
 nsCycleCollector::nsCycleCollector() : 
     mCollectionInProgress(PR_FALSE),
     mScanInProgress(PR_FALSE),
     mCollectedObjects(0),
     mWhiteNodes(nsnull),
     mWhiteNodeCount(0),
+    mVisitedRefCounted(0),
+    mVisitedGCed(0),
 #ifdef DEBUG_CC
     mPurpleBuf(mParams, mStats),
     mPtrLog(nsnull)
 #else
     mPurpleBuf(mParams)
 #endif
 {
 #ifdef DEBUG_CC
@@ -2563,16 +2571,18 @@ nsCycleCollector::PrepareForCollection(n
         return PR_FALSE;
 
     NS_TIME_FUNCTION;
 
 #ifdef COLLECT_TIME_DEBUG
     printf("cc: nsCycleCollector::PrepareForCollection()\n");
 #endif
     mCollectionStart = TimeStamp::Now();
+    mVisitedRefCounted = 0;
+    mVisitedGCed = 0;
 
     mCollectionInProgress = PR_TRUE;
 
     nsCOMPtr<nsIObserverService> obs =
         mozilla::services::GetObserverService();
     if (obs)
         obs->NotifyObservers(nsnull, "cycle-collector-begin", nsnull);
 
@@ -2597,16 +2607,19 @@ nsCycleCollector::CleanupAfterCollection
     _heapmin();
 #endif
 
     PRUint32 interval((TimeStamp::Now() - mCollectionStart).ToMilliseconds());
 #ifdef COLLECT_TIME_DEBUG
     printf("cc: CleanupAfterCollection(), total time %ums\n", interval);
 #endif
     Telemetry::Accumulate(Telemetry::CYCLE_COLLECTOR, interval);
+    Telemetry::Accumulate(Telemetry::CYCLE_COLLECTOR_VISITED_REF_COUNTED, mVisitedRefCounted);
+    Telemetry::Accumulate(Telemetry::CYCLE_COLLECTOR_VISITED_GCED, mVisitedGCed);
+    Telemetry::Accumulate(Telemetry::CYCLE_COLLECTOR_COLLECTED, mWhiteNodeCount);
 
 #ifdef DEBUG_CC
     ExplainLiveExpectedGarbage();
 #endif
 }
 
 PRUint32
 nsCycleCollector::Collect(PRUint32 aTryCollections,