Bug 1353159 - Use IPC_MESSAGE_SIZE2 to unify the expired IPC_MESSAGE_SIZE and MESSAGE_MANAGER_MESSAGE_SIZE2
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
--- a/dom/base/nsFrameMessageManager.cpp
+++ b/dom/base/nsFrameMessageManager.cpp
@@ -579,36 +579,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) {
@@ -1287,18 +1286,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
@@ -10677,25 +10677,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,
@@ -10708,27 +10708,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."
},