bug 1218576 - Pre-allocate child keyed histograms in the parent process r=gfritzsche
☠☠ backed out by 1530103e032c ☠ ☠
authorChris H-C <chutten@mozilla.com>
Wed, 29 Jun 2016 15:38:35 -0400
changeset 313019 7fdd6b6ab5945eab4bc7cddbcba34ce0c2fb2fbf
parent 313018 a0a4829d0ca0184e22e9e0232553c7ebdf0adc52
child 313020 baf105cbe0c84c9531a29d3fd0680b4b1d95563d
push id30669
push userkwierso@gmail.com
push dateThu, 08 Sep 2016 00:56:12 +0000
treeherdermozilla-central@77940cbf0c2a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgfritzsche
bugs1218576
milestone51.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 1218576 - Pre-allocate child keyed histograms in the parent process r=gfritzsche I originally thought we'd be able to avoid the previous implementation's waste of a map full of every kind of keyed histogram. Unfortunately, other code (TelemetrySession at the very least) depends on this (and will throw if a keyed histogram isn't present, even if it is empty) MozReview-Commit-ID: 8MCGVa595UB
toolkit/components/telemetry/TelemetryHistogram.cpp
--- a/toolkit/components/telemetry/TelemetryHistogram.cpp
+++ b/toolkit/components/telemetry/TelemetryHistogram.cpp
@@ -1849,22 +1849,17 @@ internal_AccumulateChildKeyed(mozilla::T
   if (!gInitDone || !internal_CanRecordBase()) {
     return;
   }
   const HistogramInfo& th = gHistograms[aId];
   nsCString id;
   id.Append(th.id());
   id.AppendLiteral(CHILD_HISTOGRAM_SUFFIX);
   KeyedHistogram* keyed = internal_GetKeyedHistogramById(id);
-  if (!keyed) {
-    const nsDependentCString expiration(th.expiration());
-    keyed = new KeyedHistogram(id, expiration, th.histogramType, th.min, th.max,
-                               th.bucketCount, th.dataset);
-    gKeyedHistograms.Put(id, keyed);
-  }
+  MOZ_ASSERT(keyed);
   keyed->Add(aKey, aSample);
 }
 
 } // namespace
 
 
 ////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////
@@ -1937,16 +1932,26 @@ void TelemetryHistogram::InitializeGloba
     if (!h.keyed) {
       continue;
     }
 
     const nsDependentCString id(h.id());
     const nsDependentCString expiration(h.expiration());
     gKeyedHistograms.Put(id, new KeyedHistogram(id, expiration, h.histogramType,
                                                 h.min, h.max, h.bucketCount, h.dataset));
+    if (XRE_IsParentProcess()) {
+      // We must create registered child keyed histograms as well or else the
+      // same code in TelemetrySession.jsm that fails without parent keyed
+      // histograms will fail without child keyed histograms.
+      nsCString childId(id);
+      childId.AppendLiteral(CHILD_HISTOGRAM_SUFFIX);
+      gKeyedHistograms.Put(childId,
+                           new KeyedHistogram(id, expiration, h.histogramType,
+                                              h.min, h.max, h.bucketCount, h.dataset));
+    }
   }
 
   // Some Telemetry histograms depend on the value of C++ constants and hardcode
   // their values in Histograms.json.
   // We add static asserts here for those values to match so that future changes
   // don't go unnoticed.
   // TODO: Compare explicitly with gHistograms[<histogram id>].bucketCount here
   // once we can make gHistograms constexpr (requires VS2015).