Bug 1441754 - Split measurements of pref callbacks in two. r=glandium
authorNicholas Nethercote <nnethercote@mozilla.com>
Wed, 28 Feb 2018 16:09:48 +1100
changeset 406508 17fe71b2e622c2ae4bfcc963156ddc8815f40dd1
parent 406507 4a6b832ce2521677f35b380245a621c2d46eb03c
child 406509 13e0252c67c9caeb7fa73ae5b2e16080c84cb728
push id100446
push usernnethercote@mozilla.com
push dateMon, 05 Mar 2018 02:52:02 +0000
treeherdermozilla-inbound@76a740cc4454 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1441754
milestone60.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 1441754 - Split measurements of pref callbacks in two. r=glandium This shows that the objects themselves are accounting for about 60% of the callback memory on 64-bit, and the domains are about 40%. MozReview-Commit-ID: JndlyIvlrGs
modules/libpref/Preferences.cpp
--- a/modules/libpref/Preferences.cpp
+++ b/modules/libpref/Preferences.cpp
@@ -300,28 +300,30 @@ struct PrefsSizes
 {
   PrefsSizes()
     : mHashTable(0)
     , mPrefValues(0)
     , mStringValues(0)
     , mCacheData(0)
     , mRootBranches(0)
     , mPrefNameArena(0)
-    , mCallbacks(0)
+    , mCallbacksObjects(0)
+    , mCallbacksDomains(0)
     , mMisc(0)
   {
   }
 
   size_t mHashTable;
   size_t mPrefValues;
   size_t mStringValues;
   size_t mCacheData;
   size_t mRootBranches;
   size_t mPrefNameArena;
-  size_t mCallbacks;
+  size_t mCallbacksObjects;
+  size_t mCallbacksDomains;
   size_t mMisc;
 };
 }
 
 static ArenaAllocator<8192, 1> gPrefNameArena;
 
 class Pref
 {
@@ -753,16 +755,22 @@ struct CallbackNode
     : mDomain(moz_xstrdup(aDomain))
     , mFunc(aFunc)
     , mData(aData)
     , mMatchKind(aMatchKind)
     , mNext(nullptr)
   {
   }
 
+  void AddSizeOfIncludingThis(MallocSizeOf aMallocSizeOf, PrefsSizes& aSizes)
+  {
+    aSizes.mCallbacksObjects += aMallocSizeOf(this);
+    aSizes.mCallbacksDomains += aMallocSizeOf(mDomain.get());
+  }
+
   UniqueFreePtr<const char> mDomain;
 
   // If someone attempts to remove the node from the callback list while
   // NotifyCallbacks() is running, |func| is set to nullptr. Such nodes will
   // be removed at the end of NotifyCallbacks().
   PrefChangedFunc mFunc;
   void* mData;
   Preferences::MatchKind mMatchKind;
@@ -2693,18 +2701,17 @@ PreferenceServiceReporter::CollectReport
     for (uint32_t i = 0, count = gCacheData->Length(); i < count; ++i) {
       sizes.mCacheData += mallocSizeOf((*gCacheData)[i]);
     }
   }
 
   sizes.mPrefNameArena += gPrefNameArena.SizeOfExcludingThis(mallocSizeOf);
 
   for (CallbackNode* node = gFirstCallback; node; node = node->mNext) {
-    sizes.mCallbacks += mallocSizeOf(node);
-    sizes.mCallbacks += mallocSizeOf(node->mDomain.get());
+    node->AddSizeOfIncludingThis(mallocSizeOf, sizes);
   }
 
   MOZ_COLLECT_REPORT("explicit/preferences/hash-table",
                      KIND_HEAP,
                      UNITS_BYTES,
                      sizes.mHashTable,
                      "Memory used by libpref's hash table.");
 
@@ -2733,22 +2740,28 @@ PreferenceServiceReporter::CollectReport
                      "Memory used by libpref's root branches.");
 
   MOZ_COLLECT_REPORT("explicit/preferences/pref-name-arena",
                      KIND_HEAP,
                      UNITS_BYTES,
                      sizes.mPrefNameArena,
                      "Memory used by libpref's arena for pref names.");
 
-  MOZ_COLLECT_REPORT("explicit/preferences/callbacks",
+  MOZ_COLLECT_REPORT("explicit/preferences/callbacks/objects",
                      KIND_HEAP,
                      UNITS_BYTES,
-                     sizes.mCallbacks,
-                     "Memory used by libpref's callbacks list, including "
-                     "pref names and prefixes.");
+                     sizes.mCallbacksObjects,
+                     "Memory used by pref callback objects.");
+
+  MOZ_COLLECT_REPORT("explicit/preferences/callbacks/domains",
+                     KIND_HEAP,
+                     UNITS_BYTES,
+                     sizes.mCallbacksDomains,
+                     "Memory used by pref callback domains (pref names and "
+                     "prefixes).");
 
   MOZ_COLLECT_REPORT("explicit/preferences/misc",
                      KIND_HEAP,
                      UNITS_BYTES,
                      sizes.mMisc,
                      "Miscellaneous memory used by libpref.");
 
   nsPrefBranch* rootBranch =