Bug 1472495: Don't report shared memmapped cache as explicit memory. r?erahm draft
authorKris Maglione <maglione.k@gmail.com>
Sat, 30 Jun 2018 16:33:50 -0700
changeset 814334 8bb19b94495ae99ec1c4083cd88bd8915003886f
parent 812906 34f927a06700696cb78789e9e77770054556212c
push id115160
push usermaglione.k@gmail.com
push dateWed, 04 Jul 2018 23:05:43 +0000
reviewerserahm
bugs1472495
milestone63.0a1
Bug 1472495: Don't report shared memmapped cache as explicit memory. r?erahm MozReview-Commit-ID: 7xWJOdg3mfg
js/xpconnect/loader/ScriptPreloader.cpp
--- a/js/xpconnect/loader/ScriptPreloader.cpp
+++ b/js/xpconnect/loader/ScriptPreloader.cpp
@@ -84,20 +84,32 @@ ScriptPreloader::CollectReports(nsIHandl
         "Memory used to hold the scripts which have been restored from the "
         "startup script cache file, but have not been executed in this session.");
 
     MOZ_COLLECT_REPORT(
         "explicit/script-preloader/heap/other", KIND_HEAP, UNITS_BYTES,
         ShallowHeapSizeOfIncludingThis(MallocSizeOf),
         "Memory used by the script cache service itself.");
 
-    MOZ_COLLECT_REPORT(
-        "explicit/script-preloader/non-heap/memmapped-cache", KIND_NONHEAP, UNITS_BYTES,
-        mCacheData.nonHeapSizeOfExcludingThis(),
-        "The memory-mapped startup script cache file.");
+    // Since the mem-mapped cache file is mapped into memory, we want to report
+    // it as explicit memory somewhere. But since the child cache is shared
+    // between all processes, we don't want to report it as explicit memory for
+    // all of them. So we report it as explicit only in the parent process, and
+    // non-explicit everywhere else.
+    if (XRE_IsParentProcess()) {
+        MOZ_COLLECT_REPORT(
+            "explicit/script-preloader/non-heap/memmapped-cache", KIND_NONHEAP, UNITS_BYTES,
+            mCacheData.nonHeapSizeOfExcludingThis(),
+            "The memory-mapped startup script cache file.");
+    } else {
+        MOZ_COLLECT_REPORT(
+            "script-preloader-memmapped-cache", KIND_NONHEAP, UNITS_BYTES,
+            mCacheData.nonHeapSizeOfExcludingThis(),
+            "The memory-mapped startup script cache file.");
+    }
 
     return NS_OK;
 }
 
 
 ScriptPreloader&
 ScriptPreloader::GetSingleton()
 {