Bug 1380770 - Add more info to GCMinor marker JSON, r=jonco
authorSteve Fink <sfink@mozilla.com>
Thu, 13 Jul 2017 17:36:46 -0700
changeset 369070 6b05837ec165b57ac8d581b8c57d1e942dbd2049
parent 369069 b3dfc5fa4c96084a4e6d24e5a632638d66f4904e
child 369071 394e4cd341caa5c111d19905913ba31c0eac4185
push id32182
push userarchaeopteryx@coole-files.de
push dateSat, 15 Jul 2017 14:35:04 +0000
treeherdermozilla-central@33d3192ed9eb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonco
bugs1380770
milestone56.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 1380770 - Add more info to GCMinor marker JSON, r=jonco
js/src/gc/Nursery.cpp
js/src/gc/Nursery.h
tools/profiler/core/ProfilerMarkerPayload.cpp
--- a/js/src/gc/Nursery.cpp
+++ b/js/src/gc/Nursery.cpp
@@ -473,26 +473,38 @@ js::Nursery::renderProfileJSON(JSONPrint
     if (!isEnabled()) {
         json.beginObject();
         json.property("status", "nursery disabled");
         json.endObject();
         return;
     }
 
     json.beginObject();
+
+    json.property("reason", JS::gcreason::ExplainReason(previousGC.reason));
+    json.property("bytes_tenured", previousGC.tenuredBytes);
+    json.floatProperty("promotion_rate",
+                       100.0 * previousGC.tenuredBytes / double(previousGC.nurseryUsedBytes), 2);
+    json.property("nursery_bytes", previousGC.nurseryUsedBytes);
+    json.property("new_nursery_bytes", numChunks() * ChunkSize);
+
+    json.beginObjectProperty("timings");
+
 #define EXTRACT_NAME(name, text) #name,
     static const char* names[] = {
 FOR_EACH_NURSERY_PROFILE_TIME(EXTRACT_NAME)
 #undef EXTRACT_NAME
     "" };
 
     size_t i = 0;
     for (auto time : profileDurations_)
         json.property(names[i++], time, json.MICROSECONDS);
 
+    json.endObject(); // timings value
+
     json.endObject();
 }
 
 /* static */ void
 js::Nursery::printProfileHeader()
 {
     fprintf(stderr, "MinorGC:               Reason  PRate Size ");
 #define PRINT_HEADER(name, text)                                              \
@@ -748,16 +760,20 @@ js::Nursery::doCollection(JS::gcreason::
     // Make sure hashtables have been updated after the collection.
     startProfile(ProfileKey::CheckHashTables);
 #ifdef JS_GC_ZEAL
     if (rt->hasZealMode(ZealMode::CheckHashTablesOnMinorGC))
         CheckHashTablesAfterMovingGC(rt);
 #endif
     endProfile(ProfileKey::CheckHashTables);
 
+    previousGC.reason = reason;
+    previousGC.nurseryUsedBytes = initialNurserySize;
+    previousGC.tenuredBytes = mover.tenuredSize;
+
     // Calculate and return the promotion rate.
     return mover.tenuredSize / double(initialNurserySize);
 }
 
 void
 js::Nursery::FreeMallocedBuffersTask::transferBuffersToFree(MallocedBuffersSet& buffersToFree,
                                                             const AutoLockHelperThreadState& lock)
 {
--- a/js/src/gc/Nursery.h
+++ b/js/src/gc/Nursery.h
@@ -348,16 +348,22 @@ class Nursery
     using ProfileDurations =
         mozilla::EnumeratedArray<ProfileKey, ProfileKey::KeyCount, mozilla::TimeDuration>;
 
     ProfileTimes startTimes_;
     ProfileDurations profileDurations_;
     ProfileDurations totalDurations_;
     uint64_t minorGcCount_;
 
+    struct {
+        JS::gcreason::Reason reason;
+        uint64_t nurseryUsedBytes;
+        uint64_t tenuredBytes;
+    } previousGC;
+
     /*
      * The set of externally malloced buffers potentially kept live by objects
      * stored in the nursery. Any external buffers that do not belong to a
      * tenured thing at the end of a minor GC must be freed.
      */
     typedef HashSet<void*, PointerHasher<void*, 3>, SystemAllocPolicy> MallocedBuffersSet;
     MallocedBuffersSet mallocedBuffers;
 
--- a/tools/profiler/core/ProfilerMarkerPayload.cpp
+++ b/tools/profiler/core/ProfilerMarkerPayload.cpp
@@ -159,13 +159,13 @@ GCMajorMarkerPayload::StreamPayload(Spli
 void
 GCMinorMarkerPayload::StreamPayload(SpliceableJSONWriter& aWriter,
                                     const TimeStamp& aProcessStartTime,
                                     UniqueStacks& aUniqueStacks)
 {
   MOZ_ASSERT(mTimingData);
   StreamCommonProps("GCMinor", aWriter, aProcessStartTime, aUniqueStacks);
   if (mTimingData) {
-    aWriter.SplicedJSONProperty("nurseryTimings", mTimingData.get());
+    aWriter.SplicedJSONProperty("nursery", mTimingData.get());
   } else {
-    aWriter.NullProperty("nurseryTimings");
+    aWriter.NullProperty("nursery");
   }
 }