Bug 920852 (part 3) - Tweak various things about RuntimeStats. r=till.
authorNicholas Nethercote <nnethercote@mozilla.com>
Tue, 24 Sep 2013 23:24:29 -0700
changeset 148926 0f1e4c73c5025e98b7112c8798a19730595a60a1
parent 148925 5337cffcd17d0085ea73e2b9940c42d5ed12c438
child 148927 6fb1c750791f9d17f12efc2af063875940515e4f
push id34384
push usernnethercote@mozilla.com
push dateFri, 27 Sep 2013 03:05:04 +0000
treeherdermozilla-inbound@6fb1c750791f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstill
bugs920852
milestone27.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 920852 (part 3) - Tweak various things about RuntimeStats. r=till.
js/public/MemoryMetrics.h
js/src/vm/MemoryMetrics.cpp
js/xpconnect/src/XPCJSRuntime.cpp
--- a/js/public/MemoryMetrics.h
+++ b/js/public/MemoryMetrics.h
@@ -341,16 +341,25 @@ struct ZoneStats : js::ZoneStatsPod
                 p->value.add(r.front().value);
             } else {
                 // We haven't seen this string before; add it to the hashtable.
                 strings.add(p, r.front().key, r.front().value);
             }
         }
     }
 
+    size_t sizeOfLiveGCThings() const {
+        size_t n = ZoneStatsPod::sizeOfLiveGCThings();
+        for (size_t i = 0; i < notableStrings.length(); i++) {
+            const JS::NotableStringInfo& info = notableStrings[i];
+            n += info.totalGCHeapSizeOf();
+        }
+        return n;
+    }
+
     typedef js::HashMap<JSString*,
                         StringInfo,
                         js::InefficientNonFlatteningStringHashPolicy,
                         js::SystemAllocPolicy> StringsHashMap;
 
     StringsHashMap strings;
     js::Vector<NotableStringInfo, 0, js::SystemAllocPolicy> notableStrings;
 };
@@ -423,19 +432,18 @@ struct CompartmentStats
 
 struct RuntimeStats
 {
 #define FOR_EACH_SIZE(macro) \
     macro(_, gcHeapChunkTotal) \
     macro(_, gcHeapDecommittedArenas) \
     macro(_, gcHeapUnusedChunks) \
     macro(_, gcHeapUnusedArenas) \
-    macro(_, gcHeapUnusedGcThings) \
     macro(_, gcHeapChunkAdmin) \
-    macro(_, gcHeapGcThings) \
+    macro(_, gcHeapGCThings) \
 
     RuntimeStats(mozilla::MallocSizeOf mallocSizeOf)
       : FOR_EACH_SIZE(ZERO_SIZE)
         runtime(),
         cTotals(),
         zTotals(),
         compartmentStatsVector(),
         zoneStatsVector(),
@@ -450,17 +458,18 @@ struct RuntimeStats
     //     - rtStats.gcHeapDecommittedArenas (decommitted arenas in non-empty chunks)
     //   - unused bytes
     //     - rtStats.gcHeapUnusedChunks (empty chunks)
     //     - rtStats.gcHeapUnusedArenas (empty arenas within non-empty chunks)
     //     - rtStats.zTotals.unusedGCThings (empty GC thing slots within non-empty arenas)
     //   - used bytes
     //     - rtStats.gcHeapChunkAdmin
     //     - rtStats.zTotals.gcHeapArenaAdmin
-    //     - rtStats.gcHeapGcThings (in-use GC things)
+    //     - rtStats.gcHeapGCThings (in-use GC things)
+    //       == rtStats.zTotals.sizeOfLiveGCThings() + rtStats.cTotals.sizeOfLiveGCThings()
     //
     // It's possible that some arenas in empty chunks may be decommitted, but
     // we don't count those under rtStats.gcHeapDecommittedArenas because (a)
     // it's rare, and (b) this means that rtStats.gcHeapUnusedChunks is a
     // multiple of the chunk size, which is good.
 
     FOR_EACH_SIZE(DECL_SIZE)
 
--- a/js/src/vm/MemoryMetrics.cpp
+++ b/js/src/vm/MemoryMetrics.cpp
@@ -445,66 +445,63 @@ JS::CollectRuntimeStats(JSRuntime *rt, R
         return false;
     rtStats->runtime.scriptSources = 0;
     IterateZonesCompartmentsArenasCells(rt, &closure, StatsZoneCallback, StatsCompartmentCallback,
                                         StatsArenaCallback, StatsCellCallback);
 
     // Take the "explicit/js/runtime/" measurements.
     rt->sizeOfIncludingThis(rtStats->mallocSizeOf_, &rtStats->runtime);
 
-    DebugOnly<size_t> totalArenaSize = 0;
-
-    rtStats->gcHeapGcThings = 0;
+    rtStats->gcHeapGCThings = 0;
     for (size_t i = 0; i < rtStats->zoneStatsVector.length(); i++) {
         ZoneStats &zStats = rtStats->zoneStatsVector[i];
 
         rtStats->zTotals.add(zStats);
-        rtStats->gcHeapGcThings += zStats.sizeOfLiveGCThings();
-#ifdef DEBUG
-        totalArenaSize += zStats.gcHeapArenaAdmin + zStats.unusedGCThings;
-#endif
 
         // Move any strings which take up more than the sundries threshold
         // (counting all of their copies together) into notableStrings.
         FindNotableStrings(zStats);
     }
 
     FindNotableStrings(rtStats->zTotals);
 
     for (size_t i = 0; i < rtStats->compartmentStatsVector.length(); i++) {
         CompartmentStats &cStats = rtStats->compartmentStatsVector[i];
-
         rtStats->cTotals.add(cStats);
-        rtStats->gcHeapGcThings += cStats.sizeOfLiveGCThings();
     }
 
+    rtStats->gcHeapGCThings = rtStats->zTotals.sizeOfLiveGCThings() +
+                              rtStats->cTotals.sizeOfLiveGCThings();
+
 #ifdef DEBUG
-    totalArenaSize += rtStats->gcHeapGcThings;
+    // Check that the in-arena measurements look ok.
+    size_t totalArenaSize = rtStats->zTotals.gcHeapArenaAdmin +
+                            rtStats->zTotals.unusedGCThings +
+                            rtStats->gcHeapGCThings;
     JS_ASSERT(totalArenaSize % gc::ArenaSize == 0);
 #endif
 
     for (CompartmentsIter comp(rt); !comp.done(); comp.next())
         comp->compartmentStats = NULL;
 
     size_t numDirtyChunks =
         (rtStats->gcHeapChunkTotal - rtStats->gcHeapUnusedChunks) / gc::ChunkSize;
     size_t perChunkAdmin =
         sizeof(gc::Chunk) - (sizeof(gc::Arena) * gc::ArenasPerChunk);
     rtStats->gcHeapChunkAdmin = numDirtyChunks * perChunkAdmin;
-    rtStats->gcHeapUnusedArenas -= rtStats->gcHeapChunkAdmin;
 
     // |gcHeapUnusedArenas| is the only thing left.  Compute it in terms of
     // all the others.  See the comment in RuntimeStats for explanation.
     rtStats->gcHeapUnusedArenas = rtStats->gcHeapChunkTotal -
                                   rtStats->gcHeapDecommittedArenas -
                                   rtStats->gcHeapUnusedChunks -
                                   rtStats->zTotals.unusedGCThings -
                                   rtStats->gcHeapChunkAdmin -
                                   rtStats->zTotals.gcHeapArenaAdmin -
-                                  rtStats->gcHeapGcThings;
+                                  rtStats->gcHeapGCThings;
     return true;
 }
 
 JS_PUBLIC_API(size_t)
 JS::SystemCompartmentCount(JSRuntime *rt)
 {
     size_t n = 0;
     for (CompartmentsIter comp(rt); !comp.done(); comp.next()) {
--- a/js/xpconnect/src/XPCJSRuntime.cpp
+++ b/js/xpconnect/src/XPCJSRuntime.cpp
@@ -2647,17 +2647,17 @@ JSReporter::CollectReports(WindowPaths *
 
     REPORT_BYTES(NS_LITERAL_CSTRING("js-main-runtime-gc-heap-committed/used/arena-admin"),
                  KIND_OTHER,
                  rtStats.zTotals.gcHeapArenaAdmin,
                  "The same as 'js-main-runtime/zones/gc-heap-arena-admin'.");
 
     REPORT_BYTES(NS_LITERAL_CSTRING("js-main-runtime-gc-heap-committed/used/gc-things"),
                  KIND_OTHER,
-                 rtStats.gcHeapGcThings,
+                 rtStats.gcHeapGCThings,
                  "Memory on the garbage-collected JavaScript heap that holds GC things such "
                  "as objects, strings, scripts, etc.")
 
     // Report xpconnect.
 
     REPORT_BYTES(NS_LITERAL_CSTRING("explicit/xpconnect"),
                  KIND_HEAP, xpconnect,
                  "Memory used by XPConnect.");