Bug 1353159 - Use IPC_MESSAGE_SIZE2 to unify the expired IPC_MESSAGE_SIZE and MESSAGE_MANAGER_MESSAGE_SIZE2 r=billm
authorHenry Chang <hchang@mozilla.com>
Thu, 04 May 2017 16:34:20 +0800
changeset 357208 3740967126ee377e579dc80f67b352f3e0ddb4f4
parent 357207 5a7a94f5364038fcc0988a3386f9b536d35ba270
child 357209 e9859494c47d6d8537d467462756580469fd9ad3
push id31788
push userkwierso@gmail.com
push dateTue, 09 May 2017 20:48:49 +0000
treeherdermozilla-central@2b6f6881a24a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs1353159
milestone55.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 1353159 - Use IPC_MESSAGE_SIZE2 to unify the expired IPC_MESSAGE_SIZE and MESSAGE_MANAGER_MESSAGE_SIZE2 r=billm The new telemetry tag is for probing the best IPC message pre-allocate size to avoid realloc overhead. We only count those message size which is greater than 4096. This tag integrates IPC_MESSAGE_SIZE and MESSAGE_MANAGER_MESSAGE_SIZE2 which have both expired. MozReview-Commit-ID: GjvuidGJ7pz
dom/base/nsFrameMessageManager.cpp
ipc/glue/MessageChannel.cpp
toolkit/components/telemetry/Histograms.json
--- a/dom/base/nsFrameMessageManager.cpp
+++ b/dom/base/nsFrameMessageManager.cpp
@@ -572,36 +572,27 @@ nsFrameMessageManager::SendRpcMessage(co
 {
   return SendMessage(aMessageName, aJSON, aObjects, aPrincipal, aCx, aArgc,
                      aRetval, false);
 }
 
 static bool
 AllowMessage(size_t aDataLength, const nsAString& aMessageName)
 {
-  static const size_t kMinTelemetryMessageSize = 8192;
-
-  if (aDataLength < kMinTelemetryMessageSize) {
-    return true;
-  }
-
-  NS_ConvertUTF16toUTF8 messageName(aMessageName);
-  messageName.StripChars("0123456789");
-
-  Telemetry::Accumulate(Telemetry::MESSAGE_MANAGER_MESSAGE_SIZE2, messageName,
-                        aDataLength);
-
   // A message includes more than structured clone data, so subtract
   // 20KB to make it more likely that a message within this bound won't
   // result in an overly large IPC message.
   static const size_t kMaxMessageSize = IPC::Channel::kMaximumMessageSize - 20 * 1024;
   if (aDataLength < kMaxMessageSize) {
     return true;
   }
 
+  NS_ConvertUTF16toUTF8 messageName(aMessageName);
+  messageName.StripChars("0123456789");
+
   Telemetry::Accumulate(Telemetry::REJECTED_MESSAGE_MANAGER_MESSAGE,
                         messageName);
 
   return false;
 }
 
 nsresult
 nsFrameMessageManager::SendMessage(const nsAString& aMessageName,
--- a/ipc/glue/MessageChannel.cpp
+++ b/ipc/glue/MessageChannel.cpp
@@ -125,17 +125,17 @@ using mozilla::MonitorAutoUnlock;
             DebugAbort(__FILE__, __LINE__, #_cond,## __VA_ARGS__);  \
     } while (0)
 
 static MessageChannel* gParentProcessBlocker;
 
 namespace mozilla {
 namespace ipc {
 
-static const uint32_t kMinTelemetryMessageSize = 8192;
+static const uint32_t kMinTelemetryMessageSize = 4096;
 
 // Note: we round the time we spend to the nearest millisecond. So a min value
 // of 1 ms actually captures from 500us and above.
 static const uint32_t kMinTelemetryIPCWriteLatencyMs = 1;
 
 // Note: we round the time we spend waiting for a response to the nearest
 // millisecond. So a min value of 1 ms actually captures from 500us and above.
 static const uint32_t kMinTelemetrySyncIPCLatencyMs = 1;
@@ -868,18 +868,17 @@ MessageChannel::Echo(Message* aMsg)
     mLink->EchoMessage(msg.forget());
     return true;
 }
 
 bool
 MessageChannel::Send(Message* aMsg)
 {
     if (aMsg->size() >= kMinTelemetryMessageSize) {
-        Telemetry::Accumulate(Telemetry::IPC_MESSAGE_SIZE,
-                              nsDependentCString(aMsg->name()), aMsg->size());
+        Telemetry::Accumulate(Telemetry::IPC_MESSAGE_SIZE2, 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_MAIN_THREAD_LATENCY_MS (time
     // from message creation to it being sent).
     if (NS_IsMainThread() && aMsg->create_time()) {
         uint32_t latencyMs = round((mozilla::TimeStamp::Now() - aMsg->create_time()).ToMilliseconds());
         if (latencyMs >= kMinTelemetryIPCWriteLatencyMs) {
@@ -1289,18 +1288,17 @@ MessageChannel::ProcessPendingRequests(A
     AssertMaybeDeferredCountCorrect();
 }
 
 bool
 MessageChannel::Send(Message* aMsg, Message* aReply)
 {
     mozilla::TimeStamp start = TimeStamp::Now();
     if (aMsg->size() >= kMinTelemetryMessageSize) {
-        Telemetry::Accumulate(Telemetry::IPC_MESSAGE_SIZE,
-                              nsDependentCString(aMsg->name()), aMsg->size());
+        Telemetry::Accumulate(Telemetry::IPC_MESSAGE_SIZE2, aMsg->size());
     }
 
     nsAutoPtr<Message> msg(aMsg);
 
     // Sanity checks.
     AssertWorkerThread();
     mMonitor->AssertNotCurrentThreadOwns();
 
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -10732,25 +10732,25 @@
   "MEDIA_DECODER_BACKEND_USED": {
     "alert_emails": ["danderson@mozilla.com"],
     "bug_numbers": [1259695],
     "expires_in_version": "never",
     "kind": "enumerated",
     "n_values": 10,
     "description": "Media decoder backend (0=WMF Software, 1=DXVA2D3D9, 2=DXVA2D3D11)"
   },
-  "IPC_MESSAGE_SIZE": {
-    "alert_emails": ["wmccloskey@mozilla.com"],
-    "bug_numbers": [1260908],
-    "expires_in_version": "55",
+  "IPC_MESSAGE_SIZE2": {
+    "alert_emails": ["hchang@mozilla.com"],
+    "bug_numbers": [1353159],
+    "expires_in_version": "60",
     "kind": "exponential",
     "high": 8000000,
     "n_buckets": 50,
-    "keyed": true,
-    "description": "Measures the size of IPC messages by message name"
+    "keyed": false,
+    "description": "Measures the size of all IPC messages sent that are >= 4096 bytes."
   },
   "IPC_REPLY_SIZE": {
     "alert_emails": ["wmccloskey@mozilla.com"],
     "bug_numbers": [1264820],
     "expires_in_version": "55",
     "kind": "exponential",
     "high": 8000000,
     "n_buckets": 50,
@@ -10763,27 +10763,16 @@
     "expires_in_version": "60",
     "kind": "exponential",
     "low": 32,
     "high": 750,
     "n_buckets": 40,
     "keyed": true,
     "description": "Measures the number of milliseconds we spend waiting for sync IPC messages to finish sending, keyed by message name. Note: only messages that wait for more than 500 microseconds and block the main thread are included in this probe."
   },
-  "MESSAGE_MANAGER_MESSAGE_SIZE2": {
-    "alert_emails": ["wmccloskey@mozilla.com","amccreight@mozilla.com"],
-    "bug_numbers": [1260908],
-    "expires_in_version": "55",
-    "kind": "exponential",
-    "low": 8192,
-    "high": 8000000,
-    "n_buckets": 50,
-    "keyed": true,
-    "description": "Each key is the message name, with digits removed, from an async message manager message that was larger than 8192 bytes, recorded in the sending process at the time of sending."
-  },
   "REJECTED_MESSAGE_MANAGER_MESSAGE": {
     "alert_emails": ["amccreight@mozilla.com"],
     "bug_numbers": [1272423],
     "expires_in_version": "55",
     "kind": "count",
     "keyed": true,
     "description": "Each key is the message name, with digits removed, from an async message manager message that was rejected for being over approximately 128MB, recorded in the sending process at the time of sending."
   },