Bug 711130 (part 3) - Use consistent names for reports of unused JS memory. r=terrence.
authorNicholas Nethercote <nnethercote@mozilla.com>
Mon, 25 Jun 2012 17:06:50 -0700
changeset 102457 a7e25244e43acfa12d70f2d9aed631b2b763cdd6
parent 102456 425e7d2dcbd7791b085f718cf2984934f282cf8d
child 102458 b81037d455e46ff77f872f16c95ab64122925f9c
push idunknown
push userunknown
push dateunknown
reviewersterrence
bugs711130
milestone16.0a1
Bug 711130 (part 3) - Use consistent names for reports of unused JS memory. r=terrence.
js/public/MemoryMetrics.h
js/src/MemoryMetrics.cpp
js/xpconnect/src/XPCJSRuntime.cpp
--- a/js/public/MemoryMetrics.h
+++ b/js/public/MemoryMetrics.h
@@ -75,17 +75,17 @@ struct RuntimeSizes
 struct CompartmentStats
 {
     CompartmentStats() {
         memset(this, 0, sizeof(*this));
     }
 
     void   *extra;
     size_t gcHeapArenaAdmin;
-    size_t gcHeapArenaUnused;
+    size_t gcHeapUnusedGcThings;
 
     size_t gcHeapObjectsNonFunction;
     size_t gcHeapObjectsFunction;
     size_t gcHeapStrings;
     size_t gcHeapShapesTree;
     size_t gcHeapShapesDict;
     size_t gcHeapShapesBase;
     size_t gcHeapScripts;
@@ -111,21 +111,21 @@ struct CompartmentStats
 
 struct RuntimeStats
 {
     RuntimeStats(JSMallocSizeOfFun mallocSizeOf)
       : runtime()
       , gcHeapChunkTotal(0)
       , gcHeapCommitted(0)
       , gcHeapUnused(0)
-      , gcHeapChunkCleanUnused(0)
-      , gcHeapChunkDirtyUnused(0)
+      , gcHeapUnusedChunks(0)
+      , gcHeapUnusedArenas(0)
       , gcHeapChunkCleanDecommitted(0)
       , gcHeapChunkDirtyDecommitted(0)
-      , gcHeapArenaUnused(0)
+      , gcHeapUnusedGcThings(0)
       , gcHeapChunkAdmin(0)
       , totalObjects(0)
       , totalShapes(0)
       , totalScripts(0)
       , totalStrings(0)
       , totalMjit(0)
       , totalTypeInference(0)
       , totalAnalysisTemp(0)
@@ -134,21 +134,21 @@ struct RuntimeStats
       , mallocSizeOf(mallocSizeOf)
     {}
 
     RuntimeSizes runtime;
 
     size_t gcHeapChunkTotal;
     size_t gcHeapCommitted;
     size_t gcHeapUnused;
-    size_t gcHeapChunkCleanUnused;
-    size_t gcHeapChunkDirtyUnused;
+    size_t gcHeapUnusedChunks;
+    size_t gcHeapUnusedArenas;
     size_t gcHeapChunkCleanDecommitted;
     size_t gcHeapChunkDirtyDecommitted;
-    size_t gcHeapArenaUnused;
+    size_t gcHeapUnusedGcThings;
     size_t gcHeapChunkAdmin;
     size_t totalObjects;
     size_t totalShapes;
     size_t totalScripts;
     size_t totalStrings;
     size_t totalMjit;
     size_t totalTypeInference;
     size_t totalAnalysisTemp;
--- a/js/src/MemoryMetrics.cpp
+++ b/js/src/MemoryMetrics.cpp
@@ -63,17 +63,17 @@ StatsArenaCallback(JSRuntime *rt, void *
     size_t allocationSpace = arena->thingsSpan(thingSize);
     rtStats->currCompartmentStats->gcHeapArenaAdmin +=
         gc::ArenaSize - allocationSpace;
 
     // We don't call the callback on unused things.  So we compute the
     // unused space like this:  arenaUnused = maxArenaUnused - arenaUsed.
     // We do this by setting arenaUnused to maxArenaUnused here, and then
     // subtracting thingSize for every used cell, in StatsCellCallback().
-    rtStats->currCompartmentStats->gcHeapArenaUnused += allocationSpace;
+    rtStats->currCompartmentStats->gcHeapUnusedGcThings += allocationSpace;
 }
 
 static void
 StatsCellCallback(JSRuntime *rt, void *data, void *thing, JSGCTraceKind traceKind,
                   size_t thingSize)
 {
     RuntimeStats *rtStats = static_cast<RuntimeStats *>(data);
     CompartmentStats *cStats = rtStats->currCompartmentStats;
@@ -143,69 +143,69 @@ StatsCellCallback(JSRuntime *rt, void *d
     case JSTRACE_XML:
     {
         cStats->gcHeapXML += thingSize;
         break;
     }
 #endif
     }
     // Yes, this is a subtraction:  see StatsArenaCallback() for details.
-    cStats->gcHeapArenaUnused -= thingSize;
+    cStats->gcHeapUnusedGcThings -= thingSize;
 }
 
 JS_PUBLIC_API(bool)
 CollectRuntimeStats(JSRuntime *rt, RuntimeStats *rtStats)
 {
     if (!rtStats->compartmentStatsVector.reserve(rt->compartments.length()))
         return false;
 
     rtStats->gcHeapChunkCleanDecommitted =
         rt->gcChunkPool.countCleanDecommittedArenas(rt) * gc::ArenaSize;
-    rtStats->gcHeapChunkCleanUnused =
+    rtStats->gcHeapUnusedChunks =
         size_t(JS_GetGCParameter(rt, JSGC_UNUSED_CHUNKS)) * gc::ChunkSize -
         rtStats->gcHeapChunkCleanDecommitted;
     rtStats->gcHeapChunkTotal =
         size_t(JS_GetGCParameter(rt, JSGC_TOTAL_CHUNKS)) * gc::ChunkSize;
 
     IterateCompartmentsArenasCells(rt, rtStats, StatsCompartmentCallback,
                                    StatsArenaCallback, StatsCellCallback);
     IterateChunks(rt, rtStats, StatsChunkCallback);
 
     rt->sizeOfIncludingThis(rtStats->mallocSizeOf, &rtStats->runtime);
 
     // This is initialized to all bytes stored in used chunks, and then we
     // subtract used space from it each time around the loop.
-    rtStats->gcHeapChunkDirtyUnused = rtStats->gcHeapChunkTotal -
-                                      rtStats->gcHeapChunkCleanUnused -
-                                      rtStats->gcHeapChunkCleanDecommitted -
-                                      rtStats->gcHeapChunkDirtyDecommitted;
+    rtStats->gcHeapUnusedArenas = rtStats->gcHeapChunkTotal -
+                                  rtStats->gcHeapUnusedChunks -
+                                  rtStats->gcHeapChunkCleanDecommitted -
+                                  rtStats->gcHeapChunkDirtyDecommitted;
 
     rtStats->totalMjit = rtStats->runtime.mjitCode;
 
     for (size_t index = 0;
          index < rtStats->compartmentStatsVector.length();
          index++) {
         CompartmentStats &cStats = rtStats->compartmentStatsVector[index];
 
         size_t used = cStats.gcHeapArenaAdmin +
-                      cStats.gcHeapArenaUnused +
+                      cStats.gcHeapUnusedGcThings +
                       cStats.gcHeapObjectsNonFunction +
                       cStats.gcHeapObjectsFunction +
                       cStats.gcHeapStrings +
                       cStats.gcHeapShapesTree +
                       cStats.gcHeapShapesDict +
                       cStats.gcHeapShapesBase +
                       cStats.gcHeapScripts +
 #if JS_HAS_XML_SUPPORT
                       cStats.gcHeapXML +
 #endif
                       cStats.gcHeapTypeObjects;
 
-        rtStats->gcHeapChunkDirtyUnused -= used;
-        rtStats->gcHeapArenaUnused += cStats.gcHeapArenaUnused;
+        rtStats->gcHeapUnusedArenas -= used;
+        rtStats->gcHeapUnusedGcThings += cStats.gcHeapUnusedGcThings;
         rtStats->totalObjects += cStats.gcHeapObjectsNonFunction +
                                  cStats.gcHeapObjectsFunction +
                                  cStats.objectSlots +
                                  cStats.objectElements +
                                  cStats.objectMisc;
         rtStats->totalShapes  += cStats.gcHeapShapesTree +
                                  cStats.gcHeapShapesDict +
                                  cStats.gcHeapShapesBase +
@@ -219,27 +219,26 @@ CollectRuntimeStats(JSRuntime *rt, Runti
         rtStats->totalMjit    += cStats.mjitData;
         rtStats->totalTypeInference += cStats.gcHeapTypeObjects +
                                        cStats.typeInferenceSizes.objects +
                                        cStats.typeInferenceSizes.scripts +
                                        cStats.typeInferenceSizes.tables;
         rtStats->totalAnalysisTemp  += cStats.typeInferenceSizes.temporary;
     }
 
-    size_t numDirtyChunks = (rtStats->gcHeapChunkTotal -
-                             rtStats->gcHeapChunkCleanUnused) /
-                            gc::ChunkSize;
+    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->gcHeapChunkDirtyUnused -= rtStats->gcHeapChunkAdmin;
+    rtStats->gcHeapUnusedArenas -= rtStats->gcHeapChunkAdmin;
 
-    rtStats->gcHeapUnused = rtStats->gcHeapChunkDirtyUnused +
-                            rtStats->gcHeapChunkCleanUnused +
-                            rtStats->gcHeapArenaUnused;
+    rtStats->gcHeapUnused = rtStats->gcHeapUnusedArenas +
+                            rtStats->gcHeapUnusedChunks +
+                            rtStats->gcHeapUnusedGcThings;
 
     rtStats->gcHeapCommitted = rtStats->gcHeapChunkTotal -
                                rtStats->gcHeapChunkCleanDecommitted -
                                rtStats->gcHeapChunkDirtyDecommitted;
 
     return true;
 }
 
--- a/js/xpconnect/src/XPCJSRuntime.cpp
+++ b/js/xpconnect/src/XPCJSRuntime.cpp
@@ -1299,21 +1299,21 @@ ReportCompartmentStats(const JS::Compart
 
     CREPORT_GC_BYTES(MakePath(pathPrefix, cStats, "gc-heap/arena-admin"),
                      cStats.gcHeapArenaAdmin,
                      "Memory on the compartment's garbage-collected JavaScript "
                      "heap, within arenas, that is used (a) to hold internal "
                      "bookkeeping information, and (b) to provide padding to "
                      "align GC things.");
 
-    CREPORT_GC_BYTES(MakePath(pathPrefix, cStats, "gc-heap/arena/unused"),
-                     cStats.gcHeapArenaUnused,
+    CREPORT_GC_BYTES(MakePath(pathPrefix, cStats, "gc-heap/unused-gc-things"),
+                     cStats.gcHeapUnusedGcThings,
                      "Memory on the compartment's garbage-collected JavaScript "
-                     "heap, within arenas, that could be holding useful data "
-                     "but currently isn't.");
+                     "heap taken by empty GC thing slots within non-empty "
+                     "arenas.");
 
     CREPORT_GC_BYTES(MakePath(pathPrefix, cStats, "gc-heap/objects/non-function"),
                      cStats.gcHeapObjectsNonFunction,
                      "Memory on the compartment's garbage-collected JavaScript "
                      "heap that holds non-function objects.");
 
     CREPORT_GC_BYTES(MakePath(pathPrefix, cStats, "gc-heap/objects/function"),
                      cStats.gcHeapObjectsFunction,
@@ -1545,31 +1545,26 @@ ReportJSRuntimeExplicitTreeStats(const J
                  "Memory used for the table holding script filenames.");
 
     REPORT_BYTES(pathPrefix + NS_LITERAL_CSTRING("runtime/compartment-objects"),
                  nsIMemoryReporter::KIND_HEAP, rtStats.runtime.compartmentObjects,
                  "Memory used for JSCompartment objects.  These are fairly "
                  "small and all the same size, so they're not worth reporting "
                  "on a per-compartment basis.");
 
-    REPORT_GC_BYTES(pathPrefix + NS_LITERAL_CSTRING("gc-heap-chunk-dirty-unused"),
-                    rtStats.gcHeapChunkDirtyUnused,
-                    "Memory on the garbage-collected JavaScript heap, within "
-                    "chunks with at least one allocated GC thing, that could "
-                    "be holding useful data but currently isn't.  Memory here "
-                    "is mutually exclusive with memory reported under "
-                    "'explicit/js/gc-heap-decommitted'.");
+    REPORT_GC_BYTES(pathPrefix + NS_LITERAL_CSTRING("gc-heap-unused-arenas"),
+                    rtStats.gcHeapUnusedArenas,
+                    "Memory on the garbage-collected JavaScript heap taken by "
+                    "empty arenas within non-empty chunks.");
 
-    REPORT_GC_BYTES(pathPrefix + NS_LITERAL_CSTRING("gc-heap-chunk-clean-unused"),
-                    rtStats.gcHeapChunkCleanUnused,
+    REPORT_GC_BYTES(pathPrefix + NS_LITERAL_CSTRING("gc-heap-unused-chunks"),
+                    rtStats.gcHeapUnusedChunks,
                     "Memory on the garbage-collected JavaScript heap taken by "
-                    "completely empty chunks, that soon will be released "
-                    "unless claimed for new allocations.  Memory here is "
-                    "mutually exclusive with memory reported under "
-                    "'explicit/js/gc-heap-decommitted'.");
+                    "empty chunks, which will soon be released unless claimed "
+                    "for new allocations.");
 
     REPORT_GC_BYTES(pathPrefix + NS_LITERAL_CSTRING("gc-heap-decommitted"),
                     rtStats.gcHeapChunkCleanDecommitted + rtStats.gcHeapChunkDirtyDecommitted,
                     "Memory in the address space of the garbage-collected "
                     "JavaScript heap that is currently returned to the OS.");
 
     REPORT_GC_BYTES(pathPrefix + NS_LITERAL_CSTRING("gc-heap-chunk-admin"),
                     rtStats.gcHeapChunkAdmin,
@@ -1706,45 +1701,45 @@ public:
             xpc::ReportJSRuntimeExplicitTreeStats(rtStats, pathPrefix, cb,
                                                   closure);
         NS_ENSURE_SUCCESS(rv, rv);
 
         REPORT_BYTES(pathPrefix + NS_LITERAL_CSTRING("xpconnect"),
                      nsIMemoryReporter::KIND_HEAP, xpconnect,
                      "Memory used by XPConnect.");
 
-        REPORT_BYTES(NS_LITERAL_CSTRING("js-main-runtime-gc-heap-chunk-dirty-unused"),
+        REPORT_BYTES(NS_LITERAL_CSTRING("js-main-runtime-gc-heap-unused-arenas"),
                      nsIMemoryReporter::KIND_OTHER,
-                     rtStats.gcHeapChunkDirtyUnused,
-                     "The same as 'explicit/js/gc-heap-chunk-dirty-unused'. "
+                     rtStats.gcHeapUnusedArenas,
+                     "The same as 'explicit/js/gc-heap-unused-arenas'. "
                      "Shown here for easy comparison with other 'js-gc' "
                      "reporters.");
 
-        REPORT_BYTES(NS_LITERAL_CSTRING("js-main-runtime-gc-heap-chunk-clean-unused"),
+        REPORT_BYTES(NS_LITERAL_CSTRING("js-main-runtime-gc-heap-unused-chunks"),
                      nsIMemoryReporter::KIND_OTHER,
-                     rtStats.gcHeapChunkCleanUnused,
-                     "The same as 'explicit/js/gc-heap-chunk-clean-unused'.  "
+                     rtStats.gcHeapUnusedChunks,
+                     "The same as 'explicit/js/gc-heap-unused-chunks'.  "
                      "Shown here for easy comparison with other 'js-gc' "
                      "reporters.");
 
-        REPORT_BYTES(NS_LITERAL_CSTRING("js-main-runtime-gc-heap-arena-unused"),
+        REPORT_BYTES(NS_LITERAL_CSTRING("js-main-runtime-gc-heap-unused-gc-things"),
                      nsIMemoryReporter::KIND_OTHER,
-                     rtStats.gcHeapArenaUnused,
+                     rtStats.gcHeapUnusedGcThings,
                      "Memory on the main JSRuntime's garbage-collected "
-                     "JavaScript heap, within arenas, that could be holding "
-                     "useful data but currently isn't. This is the sum of all "
-                     "compartments' 'gc-heap/arena-unused' numbers.");
+                     "JavaScript heap taken by empty GC thing slots within "
+                     "non-empty arenas. This is the sum of all compartments' "
+                     "'gc-heap/unused-gc-things' numbers.");
 
         REPORT_BYTES(NS_LITERAL_CSTRING("js-main-runtime-gc-heap-committed-unused"),
                      nsIMemoryReporter::KIND_OTHER,
                      rtStats.gcHeapUnused,
                      "Amount of the GC heap that's committed, but that is "
                      "neither part of an active allocation nor being used for "
-                     "bookkeeping.  Equal to 'gc-heap-chunk-dirty-unused' + "
-                     "'gc-heap-chunk-clean-unused' + 'gc-heap-arena-unused'.");
+                     "bookkeeping.  Equal to 'gc-heap-unused-chunks' + "
+                     "'gc-heap-unused-arenas' + 'gc-heap-unused-gc-things'.");
 
         // Why 10000x?  100x because it's a percentage, and another 100x
         // because nsIMemoryReporter requires that for UNITS_PERCENTAGE
         // reporters so we can get two decimal places out of the integer value.
         REPORT(NS_LITERAL_CSTRING("js-main-runtime-gc-heap-committed-unused-ratio"),
                nsIMemoryReporter::KIND_OTHER,
                nsIMemoryReporter::UNITS_PERCENTAGE,
                (PRInt64) 10000 * rtStats.gcHeapUnused /