Bug 1517409 - (part 4) Add a postCapacity measurement r=jonco
authorPaul Bone <pbone@mozilla.com>
Thu, 17 Jan 2019 16:29:10 +1100
changeset 514398 9ac2f47b3cc21276f6d8306175a4f428dcd4378f
parent 514397 4b29deaac54a9d52b32d2ecdd000c4da06f6ac86
child 514399 3aa256c255f664c500714c34a3b9e353e545d196
child 514500 a7238b0eac40faf3472969790f8b7849ad2677c5
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonco
bugs1517409
milestone66.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 1517409 - (part 4) Add a postCapacity measurement r=jonco Alternative version of part 4 which does not add new telemetry.
js/src/gc/Statistics.cpp
js/src/gc/Statistics.h
--- a/js/src/gc/Statistics.cpp
+++ b/js/src/gc/Statistics.cpp
@@ -601,17 +601,17 @@ UniqueChars Statistics::renderJsonMessag
   Sprinter printer(nullptr, false);
   if (!printer.init()) {
     return UniqueChars(nullptr);
   }
   JSONPrinter json(printer);
 
   json.beginObject();
   json.property("status", "completed");    // JSON Key #1
-  formatJsonDescription(timestamp, json);  // #2-22
+  formatJsonDescription(timestamp, json, use);  // #2-22
 
   if (use == Statistics::JSONUse::TELEMETRY) {
     json.beginListProperty("slices_list");  // #23
     for (unsigned i = 0; i < slices_.length(); i++) {
       formatJsonSlice(i, json);
     }
     json.endList();
   }
@@ -621,17 +621,18 @@ UniqueChars Statistics::renderJsonMessag
   json.endObject();
 
   json.endObject();
 
   return printer.release();
 }
 
 void Statistics::formatJsonDescription(uint64_t timestamp,
-                                       JSONPrinter& json) const {
+                                       JSONPrinter& json,
+                                       JSONUse use) const {
   // If you change JSON properties here, please update:
   // Telemetry ping code:
   //   toolkit/components/telemetry/other/GCTelemetry.jsm
   // Telemetry documentation:
   //   toolkit/components/telemetry/docs/data/main-ping.rst
   // Telemetry tests:
   //   toolkit/components/telemetry/tests/browser/browser_TelemetryGC.js,
   //   toolkit/components/telemetry/tests/unit/test_TelemetryGC.js
@@ -671,16 +672,20 @@ void Statistics::formatJsonDescription(u
   json.property("scc_sweep_max_pause", sccLongest,
                 JSONPrinter::MILLISECONDS);  // #15
 
   if (nonincrementalReason_ != AbortReason::None) {
     json.property("nonincremental_reason",
                   ExplainAbortReason(nonincrementalReason_));  // #16
   }
   json.property("allocated_bytes", preHeapSize);  // #17
+  if (use == Statistics::JSONUse::PROFILER) {
+    json.property("post_heap_size", postHeapSize);
+  }
+
   uint32_t addedChunks = getCount(COUNT_NEW_CHUNK);
   if (addedChunks) {
     json.property("added_chunks", addedChunks);  // #18
   }
   uint32_t removedChunks = getCount(COUNT_DESTROY_CHUNK);
   if (removedChunks) {
     json.property("removed_chunks", removedChunks);  // #19
   }
@@ -737,16 +742,17 @@ void Statistics::formatJsonPhaseTimes(co
 
 Statistics::Statistics(JSRuntime* rt)
     : runtime(rt),
       gcTimerFile(nullptr),
       gcDebugFile(nullptr),
       nonincrementalReason_(gc::AbortReason::None),
       allocsSinceMinorGC({0, 0}),
       preHeapSize(0),
+      postHeapSize(0),
       thresholdTriggered(false),
       triggerAmount(0.0),
       triggerThreshold(0.0),
       startingMinorGCNumber(0),
       startingMajorGCNumber(0),
       startingSliceNumber(0),
       maxPauseInInterval(0),
       sliceCallback(nullptr),
@@ -973,16 +979,17 @@ void Statistics::beginGC(JSGCInvocationK
   preHeapSize = runtime->gc.heapSize.gcBytes();
   startingMajorGCNumber = runtime->gc.majorGCCount();
   startingSliceNumber = runtime->gc.gcNumber();
 }
 
 void Statistics::endGC() {
   TimeDuration sccTotal, sccLongest;
   sccDurations(&sccTotal, &sccLongest);
+  postHeapSize = runtime->gc.heapSize.gcBytes();
 
   runtime->addTelemetry(JS_TELEMETRY_GC_IS_ZONE_GC,
                         !zoneStats.isFullCollection());
   TimeDuration markTotal = SumPhase(PhaseKind::MARK, phaseTimes);
   TimeDuration markRootsTotal = SumPhase(PhaseKind::MARK_ROOTS, phaseTimes);
   double markTime = t(markTotal);
   size_t markCount = runtime->gc.marker.getMarkCount();
   double markRate = markCount / markTime;
--- a/js/src/gc/Statistics.h
+++ b/js/src/gc/Statistics.h
@@ -287,17 +287,17 @@ struct Statistics {
   void printTotalProfileTimes();
 
   enum JSONUse {
     TELEMETRY,
     PROFILER
   };
 
   // Return JSON for a whole major GC.  If use == PROFILER then
-  // detailed per-slice data will be included.
+  // detailed per-slice data and some other fields will be included.
   UniqueChars renderJsonMessage(uint64_t timestamp, JSONUse use) const;
 
   // Return JSON for the timings of just the given slice.
   UniqueChars renderJsonSlice(size_t sliceNum) const;
 
   // Return JSON for the previous nursery collection.
   UniqueChars renderNurseryJson(JSRuntime* rt) const;
 
@@ -355,18 +355,19 @@ struct Statistics {
    * These events cannot be kept in the above array, we need to take their
    * address.
    */
   struct {
     uint32_t nursery;
     uint32_t tenured;
   } allocsSinceMinorGC;
 
-  /* Heap size before the GC started. */
+  /* Heap size before and after the GC ran. */
   size_t preHeapSize;
+  size_t postHeapSize;
 
   /* If the GC was triggered by exceeding some threshold, record the
    * threshold and the value that exceeded it. */
   bool thresholdTriggered;
   double triggerAmount;
   double triggerThreshold;
 
   /* GC numbers as of the beginning of the collection. */
@@ -438,17 +439,17 @@ struct Statistics {
       const PhaseTimeTable& phaseTimes) const;
 
   UniqueChars formatDetailedDescription() const;
   UniqueChars formatDetailedSliceDescription(unsigned i,
                                              const SliceData& slice) const;
   UniqueChars formatDetailedPhaseTimes(const PhaseTimeTable& phaseTimes) const;
   UniqueChars formatDetailedTotals() const;
 
-  void formatJsonDescription(uint64_t timestamp, JSONPrinter&) const;
+  void formatJsonDescription(uint64_t timestamp, JSONPrinter&, JSONUse) const;
   void formatJsonSliceDescription(unsigned i, const SliceData& slice,
                                   JSONPrinter&) const;
   void formatJsonPhaseTimes(const PhaseTimeTable& phaseTimes,
                             JSONPrinter&) const;
   void formatJsonSlice(size_t sliceNum, JSONPrinter&) const;
 
   double computeMMU(TimeDuration resolution) const;