Bug 913881, part 6 - Measure weak map representations in the cycle collector graph. r=njn
authorAndrew McCreight <continuation@gmail.com>
Tue, 10 Sep 2013 08:56:36 -0700
changeset 159348 fb46afe7f48b31e86a5a78f2c0b7fa6ce25c9f2a
parent 159347 a36c944c929ed44a0ca361743cab150eca1be7c6
child 159349 08977d6b4bf19163ce52e6870156787c988af231
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs913881
milestone26.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 913881, part 6 - Measure weak map representations in the cycle collector graph. r=njn Contrary to the comment here, I'm pretty sure this needs to be measured. mWeakMaps is an array of little structs. Of course, in practice I doubt this amounts to anything.
xpcom/base/nsCycleCollector.cpp
--- a/xpcom/base/nsCycleCollector.cpp
+++ b/xpcom/base/nsCycleCollector.cpp
@@ -611,22 +611,24 @@ struct GCGraph
     {
         mNodes.Clear();
         mEdges.Clear();
         mWeakMaps.Clear();
         mRootCount = 0;
     }
 
     void SizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
-                             size_t *aNodesSize, size_t *aEdgesSize) const {
+                             size_t *aNodesSize, size_t *aEdgesSize,
+                             size_t *aWeakMapsSize) const {
         *aNodesSize = mNodes.SizeOfExcludingThis(aMallocSizeOf);
         *aEdgesSize = mEdges.SizeOfExcludingThis(aMallocSizeOf);
 
-        // These fields are deliberately not measured:
-        // - mWeakMaps entries, because the pointers are non-owning
+        // We don't measure what the WeakMappings point to, because the
+        // pointers are non-owning.
+        *aWeakMapsSize = mWeakMaps.SizeOfExcludingThis(aMallocSizeOf);
     }
 };
 
 static nsISupports *
 CanonicalizeXPCOMParticipant(nsISupports *in)
 {
     nsISupports* out;
     in->QueryInterface(NS_GET_IID(nsCycleCollectionISupports),
@@ -971,16 +973,17 @@ public:
                  nsCycleCollectorResults *aResults,
                  nsICycleCollectorListener *aListener);
     void Shutdown();
 
     void SizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
                              size_t *aObjectSize,
                              size_t *aGraphNodesSize,
                              size_t *aGraphEdgesSize,
+                             size_t *aWeakMapsSize,
                              size_t *aWhiteNodeSize,
                              size_t *aPurpleBufferSize) const;
 
 private:
     void CheckThreadSafety();
     void ShutdownCollect(nsICycleCollectorListener *aListener);
 
     void PrepareForCollection(nsCycleCollectorResults *aResults,
@@ -2400,21 +2403,23 @@ class CycleCollectorMultiReporter MOZ_FI
     {
         name.AssignLiteral("cycle-collector");
         return NS_OK;
     }
 
     NS_IMETHOD CollectReports(nsIMemoryMultiReporterCallback* aCb,
                               nsISupports* aClosure)
     {
-        size_t objectSize, graphNodesSize, graphEdgesSize, whiteNodesSize,
-               purpleBufferSize;
+        size_t objectSize, graphNodesSize, graphEdgesSize, weakMapsSize,
+            whiteNodesSize, purpleBufferSize;
         mCollector->SizeOfIncludingThis(MallocSizeOf,
-                                        &objectSize, &graphNodesSize,
-                                        &graphEdgesSize, &whiteNodesSize,
+                                        &objectSize,
+                                        &graphNodesSize, &graphEdgesSize,
+                                        &weakMapsSize,
+                                        &whiteNodesSize,
                                         &purpleBufferSize);
 
     #define REPORT(_path, _amount, _desc)                                     \
         do {                                                                  \
             size_t amount = _amount;  /* evaluate |_amount| only once */      \
             if (amount > 0) {                                                 \
                 nsresult rv;                                                  \
                 rv = aCb->Callback(EmptyCString(), NS_LITERAL_CSTRING(_path), \
@@ -2431,16 +2436,21 @@ class CycleCollectorMultiReporter MOZ_FI
         REPORT("explicit/cycle-collector/graph-nodes", graphNodesSize,
                "Memory used for the nodes of the cycle collector's graph. "
                "This should be zero when the collector is idle.");
 
         REPORT("explicit/cycle-collector/graph-edges", graphEdgesSize,
                "Memory used for the edges of the cycle collector's graph. "
                "This should be zero when the collector is idle.");
 
+        REPORT("explicit/cycle-collector/weak-maps", weakMapsSize,
+               "Memory used for the representation of weak maps in the "
+               "cycle collector's graph. "
+               "This should be zero when the collector is idle.");
+
         REPORT("explicit/cycle-collector/white-nodes", whiteNodesSize,
                "Memory used for the cycle collector's white nodes array. "
                "This should be zero when the collector is idle.");
 
         REPORT("explicit/cycle-collector/purple-buffer", purpleBufferSize,
                "Memory used for the cycle collector's purple buffer.");
 
     #undef REPORT
@@ -2812,22 +2822,24 @@ nsCycleCollector::Shutdown()
     }
 }
 
 void
 nsCycleCollector::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
                                       size_t *aObjectSize,
                                       size_t *aGraphNodesSize,
                                       size_t *aGraphEdgesSize,
+                                      size_t *aWeakMapsSize,
                                       size_t *aWhiteNodeSize,
                                       size_t *aPurpleBufferSize) const
 {
     *aObjectSize = aMallocSizeOf(this);
 
-    mGraph.SizeOfExcludingThis(aMallocSizeOf, aGraphNodesSize, aGraphEdgesSize);
+    mGraph.SizeOfExcludingThis(aMallocSizeOf, aGraphNodesSize, aGraphEdgesSize,
+                               aWeakMapsSize);
 
     // No need to measure what the entries point to; the pointers are
     // non-owning.
     *aWhiteNodeSize = mWhiteNodes
                     ? mWhiteNodes->SizeOfIncludingThis(aMallocSizeOf)
                     : 0;
 
     *aPurpleBufferSize = mPurpleBuf.SizeOfExcludingThis(aMallocSizeOf);