Bug 1346866 - Make the IPC serialization/deserialization time probes main-thread-only. r=billm, a=gchang
authorMichael Layzell <michael@thelayzells.com>
Thu, 16 Mar 2017 11:12:00 -0400
changeset 395262 ede05196d436e933a9224c3b3ca1822a3f82265b
parent 395261 cc3b9a4c673ed6e647348c4bcc73ef5851a50585
child 395263 0496e366a8f4d1393a8caba1db5f6d1f49da468d
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm, gchang
bugs1346866
milestone54.0a2
Bug 1346866 - Make the IPC serialization/deserialization time probes main-thread-only. r=billm, a=gchang MozReview-Commit-ID: 5Sc820Jh494
ipc/chromium/src/base/pickle.cc
ipc/glue/MessageChannel.cpp
toolkit/components/telemetry/Histograms.json
--- a/ipc/chromium/src/base/pickle.cc
+++ b/ipc/chromium/src/base/pickle.cc
@@ -453,20 +453,20 @@ bool Pickle::ReadSentinel(PickleIterator
 bool Pickle::WriteSentinel(uint32_t sentinel) {
   return WriteUInt32(sentinel);
 }
 #endif
 
 void Pickle::EndRead(PickleIterator& iter, uint32_t ipcMsgType) const {
   DCHECK(iter.iter_.Done());
 
-  if (ipcMsgType != 0) {
+  if (NS_IsMainThread() && ipcMsgType != 0) {
     uint32_t latencyMs = round((mozilla::TimeStamp::Now() - iter.start_).ToMilliseconds());
     if (latencyMs >= kMinTelemetryIPCReadLatencyMs) {
-      mozilla::Telemetry::Accumulate(mozilla::Telemetry::IPC_READ_LATENCY_MS,
+      mozilla::Telemetry::Accumulate(mozilla::Telemetry::IPC_READ_MAIN_THREAD_LATENCY_MS,
                                      nsDependentCString(mozilla::ipc::StringFromIPCMessageType(ipcMsgType)),
                                      latencyMs);
     }
   }
 }
 
 void Pickle::BeginWrite(uint32_t length, uint32_t alignment) {
   DCHECK(alignment % 4 == 0) << "Must be at least 32-bit aligned!";
--- a/ipc/glue/MessageChannel.cpp
+++ b/ipc/glue/MessageChannel.cpp
@@ -781,22 +781,22 @@ bool
 MessageChannel::Send(Message* aMsg)
 {
     if (aMsg->size() >= kMinTelemetryMessageSize) {
         Telemetry::Accumulate(Telemetry::IPC_MESSAGE_SIZE,
                               nsDependentCString(aMsg->name()), aMsg->size());
     }
 
     // If the message was created by the IPC bindings, the create time will be
-    // recorded. Use this information to report the IPC_WRITE_LATENCY_MS (time
+    // recorded. Use this information to report the IPC_WRITE_MAIN_THREAD_LATENCY_MS (time
     // from message creation to it being sent).
-    if (aMsg->create_time()) {
+    if (NS_IsMainThread() && aMsg->create_time()) {
         uint32_t latencyMs = round((mozilla::TimeStamp::Now() - aMsg->create_time()).ToMilliseconds());
         if (latencyMs >= kMinTelemetryIPCWriteLatencyMs) {
-            mozilla::Telemetry::Accumulate(mozilla::Telemetry::IPC_WRITE_LATENCY_MS,
+            mozilla::Telemetry::Accumulate(mozilla::Telemetry::IPC_WRITE_MAIN_THREAD_LATENCY_MS,
                                            nsDependentCString(aMsg->name()),
                                            latencyMs);
         }
     }
 
     MOZ_RELEASE_ASSERT(!aMsg->is_sync());
     MOZ_RELEASE_ASSERT(aMsg->nested_level() != IPC::Message::NESTED_INSIDE_SYNC);
 
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -11076,29 +11076,29 @@
   "BUSY_TAB_ABANDONED": {
     "alert_emails": ["hkirschner@mozilla.com"],
     "expires_in_version": "60",
     "kind": "categorical",
     "bug_numbers": [1307689],
     "description": "Records a value each time a tab that is showing the loading throbber is interrupted. Desktop only.",
     "labels": ["stop", "back", "forward", "historyNavigation", "reload", "tabClosed", "newURI"]
   },
-  "IPC_READ_LATENCY_MS": {
+  "IPC_READ_MAIN_THREAD_LATENCY_MS": {
     "alert_emails": ["mlayzell@mozilla.com"],
     "bug_numbers": [1342635],
     "expires_in_version": "60",
     "kind": "exponential",
     "high": 500,
     "n_buckets": 20,
     "keyed": true,
-    "description": "Measures the number of milliseconds we spend waiting for IPC messages to deserialize their parameters. Note: only messages that take more than 500 microseconds are included in this probe. This probe is keyed on the IPDL message name."
-  },
-  "IPC_WRITE_LATENCY_MS": {
+    "description": "Measures the number of milliseconds we spend waiting on the main thread for IPC messages to deserialize their parameters. Note: only messages that take more than 500 microseconds are included in this probe. This probe is keyed on the IPDL message name."
+  },
+  "IPC_WRITE_MAIN_THREAD_LATENCY_MS": {
     "alert_emails": ["mlayzell@mozilla.com"],
     "bug_numbers": [1342635],
     "expires_in_version": "60",
     "kind": "exponential",
     "high": 500,
     "n_buckets": 20,
     "keyed": true,
-    "description": "Measures the number of milliseconds we spend waiting for IPC messages to serialize their parameters. Note: only messages that take more than 500 microseconds are included in this probe. This probe is keyed on the IPDL message name."
+    "description": "Measures the number of milliseconds we spend waiting on the main thread for IPC messages to serialize their parameters. Note: only messages that take more than 500 microseconds are included in this probe. This probe is keyed on the IPDL message name."
   }
 }