bug 1312778 - Ensure histogram recording is enabled before remote accumulation r=gfritzsche
☠☠ backed out by d0f5bb427e0f ☠ ☠
authorChris H-C <chutten@mozilla.com>
Wed, 26 Oct 2016 11:17:50 -0400
changeset 346973 ee32f39572dd76c9b6db98831d61b54c668147f5
parent 346972 ad425b5dd87b5bae73defea1f58287306dfa9484
child 346974 04ed5f3ad61afdef4511a5455198488839c55025
push id10298
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:33:03 +0000
treeherdermozilla-aurora@7e29173b1641 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgfritzsche
bugs1312778
milestone52.0a1
bug 1312778 - Ensure histogram recording is enabled before remote accumulation r=gfritzsche There is a mechanism to selectively turn hgram recording off and on. This is presently only used to throttle an otherwise-devastatingly-chatty hgram to only contain accumulations from specific times (sync scroll). This was only checked on the parent. This checks it on the child as well. MozReview-Commit-ID: 4f0VXMHLaPW
toolkit/components/telemetry/TelemetryHistogram.cpp
toolkit/components/telemetry/tests/unit/test_ChildHistograms.js
--- a/toolkit/components/telemetry/TelemetryHistogram.cpp
+++ b/toolkit/components/telemetry/TelemetryHistogram.cpp
@@ -1336,16 +1336,21 @@ void internal_armIPCTimer()
 }
 
 bool
 internal_RemoteAccumulate(mozilla::Telemetry::ID aId, uint32_t aSample)
 {
   if (XRE_IsParentProcess()) {
     return false;
   }
+  Histogram *h;
+  nsresult rv = internal_GetHistogramByEnumId(aId, &h);
+  if (NS_SUCCEEDED(rv) && !h->IsRecordingEnabled()) {
+    return true;
+  }
   if (!gAccumulations) {
     gAccumulations = new nsTArray<Accumulation>();
   }
   if (gAccumulations->Length() == kAccumulationsArrayHighWaterMark) {
     NS_DispatchToMainThread(NS_NewRunnableFunction([]() -> void {
       TelemetryHistogram::IPCTimerFired(nullptr, nullptr);
     }));
   }
@@ -1356,16 +1361,23 @@ internal_RemoteAccumulate(mozilla::Telem
 
 bool
 internal_RemoteAccumulate(mozilla::Telemetry::ID aId,
                     const nsCString& aKey, uint32_t aSample)
 {
   if (XRE_IsParentProcess()) {
     return false;
   }
+  const HistogramInfo& th = gHistograms[aId];
+  KeyedHistogram* keyed
+     = internal_GetKeyedHistogramById(nsDependentCString(th.id()));
+  MOZ_ASSERT(keyed);
+  if (!keyed->IsRecordingEnabled()) {
+    return false;
+  }
   if (!gKeyedAccumulations) {
     gKeyedAccumulations = new nsTArray<KeyedAccumulation>();
   }
   if (gKeyedAccumulations->Length() == kAccumulationsArrayHighWaterMark) {
     NS_DispatchToMainThread(NS_NewRunnableFunction([]() -> void {
       TelemetryHistogram::IPCTimerFired(nullptr, nullptr);
     }));
   }
--- a/toolkit/components/telemetry/tests/unit/test_ChildHistograms.js
+++ b/toolkit/components/telemetry/tests/unit/test_ChildHistograms.js
@@ -13,26 +13,33 @@ const APP_VERSION = "1";
 const APP_ID = "xpcshell@tests.mozilla.org";
 const APP_NAME = "XPCShell";
 
 function run_child_test() {
   // Setup histograms with some fixed values.
   let flagHist = Telemetry.getHistogramById("TELEMETRY_TEST_FLAG");
   flagHist.add(1);
   let countHist = Telemetry.getHistogramById("TELEMETRY_TEST_COUNT");
+  Telemetry.setHistogramRecordingEnabled("TELEMETRY_TEST_COUNT", false);
+  countHist.add();
+  Telemetry.setHistogramRecordingEnabled("TELEMETRY_TEST_COUNT", true);
   countHist.add();
   countHist.add();
   let categHist = Telemetry.getHistogramById("TELEMETRY_TEST_CATEGORICAL");
   categHist.add("Label2");
   categHist.add("Label3");
 
   let flagKeyed = Telemetry.getKeyedHistogramById("TELEMETRY_TEST_KEYED_FLAG");
   flagKeyed.add("a", 1);
   flagKeyed.add("b", 1);
   let countKeyed = Telemetry.getKeyedHistogramById("TELEMETRY_TEST_KEYED_COUNT");
+  Telemetry.setHistogramRecordingEnabled("TELEMETRY_TEST_KEYED_COUNT", false);
+  countKeyed.add("a");
+  countKeyed.add("b");
+  Telemetry.setHistogramRecordingEnabled("TELEMETRY_TEST_KEYED_COUNT", true);
   countKeyed.add("a");
   countKeyed.add("b");
   countKeyed.add("b");
 }
 
 function check_histogram_values(payload) {
   const hs = payload.histograms;
   Assert.ok("TELEMETRY_TEST_COUNT" in hs, "Should have count test histogram.");