Bug 1637642 - Add telemetry for GC preparation phase that occurs before root marking r=sfink
authorJon Coppeard <jcoppeard@mozilla.com>
Fri, 15 May 2020 07:14:39 +0000
changeset 530227 71f6facd478a4f18a67d6012341c2464d4a67a74
parent 530226 fd4f1d747f5bef011671c801a1d75580858bcb1e
child 530228 0e0c8a33d904b21b9a7db9ef210530e34ca8cd05
push id37420
push usernerli@mozilla.com
push dateFri, 15 May 2020 21:52:36 +0000
treeherdermozilla-central@f340bbb582d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs1637642
milestone78.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 1637642 - Add telemetry for GC preparation phase that occurs before root marking r=sfink Differential Revision: https://phabricator.services.mozilla.com/D75148
js/src/gc/Statistics.cpp
js/src/jsfriendapi.h
js/xpconnect/src/XPCJSRuntime.cpp
toolkit/components/telemetry/Histograms.json
--- a/js/src/gc/Statistics.cpp
+++ b/js/src/gc/Statistics.cpp
@@ -1057,22 +1057,23 @@ void Statistics::endGC() {
 
   sendGCTelemetry();
 }
 
 void Statistics::sendGCTelemetry() {
   JSRuntime* runtime = gc->rt;
   runtime->addTelemetry(JS_TELEMETRY_GC_IS_ZONE_GC,
                         !zoneStats.isFullCollection());
+  TimeDuration prepareTotal = SumPhase(PhaseKind::PREPARE, phaseTimes);
   TimeDuration markTotal = SumPhase(PhaseKind::MARK, phaseTimes);
   TimeDuration markRootsTotal = SumPhase(PhaseKind::MARK_ROOTS, phaseTimes);
-  double markTime = t(markTotal);
   size_t markCount = gc->marker.getMarkCount();
-  double markRate = markCount / markTime;
-  runtime->addTelemetry(JS_TELEMETRY_GC_MARK_MS, markTime);
+  double markRate = markCount / t(markTotal);
+  runtime->addTelemetry(JS_TELEMETRY_GC_PREPARE_MS, t(prepareTotal));
+  runtime->addTelemetry(JS_TELEMETRY_GC_MARK_MS, t(markTotal));
   runtime->addTelemetry(JS_TELEMETRY_GC_MARK_RATE, markRate);
   runtime->addTelemetry(JS_TELEMETRY_GC_SWEEP_MS, t(phaseTimes[Phase::SWEEP]));
   if (gc->isCompactingGc()) {
     runtime->addTelemetry(JS_TELEMETRY_GC_COMPACT_MS,
                           t(phaseTimes[Phase::COMPACT]));
   }
   runtime->addTelemetry(JS_TELEMETRY_GC_MARK_ROOTS_MS, t(markRootsTotal));
   runtime->addTelemetry(JS_TELEMETRY_GC_MARK_GRAY_MS,
--- a/js/src/jsfriendapi.h
+++ b/js/src/jsfriendapi.h
@@ -143,16 +143,17 @@ extern JS_FRIEND_API void JS_TraceObject
 enum {
   JS_TELEMETRY_GC_REASON,
   JS_TELEMETRY_GC_IS_ZONE_GC,
   JS_TELEMETRY_GC_MS,
   JS_TELEMETRY_GC_BUDGET_MS,
   JS_TELEMETRY_GC_BUDGET_OVERRUN,
   JS_TELEMETRY_GC_ANIMATION_MS,
   JS_TELEMETRY_GC_MAX_PAUSE_MS_2,
+  JS_TELEMETRY_GC_PREPARE_MS,
   JS_TELEMETRY_GC_MARK_MS,
   JS_TELEMETRY_GC_SWEEP_MS,
   JS_TELEMETRY_GC_COMPACT_MS,
   JS_TELEMETRY_GC_MARK_ROOTS_MS,
   JS_TELEMETRY_GC_MARK_GRAY_MS,
   JS_TELEMETRY_GC_SLICE_MS,
   JS_TELEMETRY_GC_SLOW_PHASE,
   JS_TELEMETRY_GC_SLOW_TASK,
--- a/js/xpconnect/src/XPCJSRuntime.cpp
+++ b/js/xpconnect/src/XPCJSRuntime.cpp
@@ -2598,16 +2598,19 @@ static void AccumulateTelemetryCallback(
       Telemetry::Accumulate(Telemetry::GC_BUDGET_OVERRUN, sample);
       break;
     case JS_TELEMETRY_GC_ANIMATION_MS:
       Telemetry::Accumulate(Telemetry::GC_ANIMATION_MS, sample);
       break;
     case JS_TELEMETRY_GC_MAX_PAUSE_MS_2:
       Telemetry::Accumulate(Telemetry::GC_MAX_PAUSE_MS_2, sample);
       break;
+    case JS_TELEMETRY_GC_PREPARE_MS:
+      Telemetry::Accumulate(Telemetry::GC_PREPARE_MS, sample);
+      break;
     case JS_TELEMETRY_GC_MARK_MS:
       Telemetry::Accumulate(Telemetry::GC_MARK_MS, sample);
       break;
     case JS_TELEMETRY_GC_SWEEP_MS:
       Telemetry::Accumulate(Telemetry::GC_SWEEP_MS, sample);
       break;
     case JS_TELEMETRY_GC_COMPACT_MS:
       Telemetry::Accumulate(Telemetry::GC_COMPACT_MS, sample);
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -706,16 +706,28 @@
     "bug_numbers": [1364503],
     "expires_in_version": "never",
     "kind": "exponential",
     "high": 10000,
     "n_buckets": 50,
     "releaseChannelCollection": "opt-out",
     "description": "Longest GC slice in a GC (ms)"
   },
+  "GC_PREPARE_MS": {
+    "record_in_processes": ["main", "content"],
+    "products": ["firefox"],
+    "alert_emails": ["dev-telemetry-gc-alerts@mozilla.org", "jcoppeard@mozilla.com"],
+    "expires_in_version": "never",
+    "releaseChannelCollection": "opt-out",
+    "kind": "exponential",
+    "high": 1000,
+    "n_buckets": 50,
+    "description": "Time spent running JS GC preparation phase (ms)",
+    "bug_numbers": [1637642]
+  },
   "GC_MARK_MS": {
     "record_in_processes": ["main", "content"],
     "products": ["firefox", "fennec", "geckoview"],
     "alert_emails": ["dev-telemetry-gc-alerts@mozilla.org"],
     "expires_in_version": "never",
     "kind": "exponential",
     "high": 10000,
     "n_buckets": 50,