From b3613ec89e2dba3ad10e6e5e53da81e432c1615f Mon Sep 17 00:00:00 2001 From: Bill McCloskey Date: Wed, 30 Mar 2016 15:25:54 -0700 Subject: [PATCH] Bug 1260908 - Record IPC message sizes (r=dvander) --- dom/base/nsFrameMessageManager.cpp | 14 ++++++++++++++ ipc/glue/MessageChannel.cpp | 10 ++++++++++ toolkit/components/telemetry/Histograms.json | 20 ++++++++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/dom/base/nsFrameMessageManager.cpp b/dom/base/nsFrameMessageManager.cpp index 659051db2772..7dc84105da91 100644 --- a/dom/base/nsFrameMessageManager.cpp +++ b/dom/base/nsFrameMessageManager.cpp @@ -69,6 +69,8 @@ using namespace mozilla; using namespace mozilla::dom; using namespace mozilla::dom::ipc; +static const int kMinTelemetryMessageSize = 8192; + nsFrameMessageManager::nsFrameMessageManager(mozilla::dom::ipc::MessageManagerCallback* aCallback, nsFrameMessageManager* aParentManager, /* mozilla::dom::ipc::MessageManagerFlags */ uint32_t aFlags) @@ -730,6 +732,12 @@ nsFrameMessageManager::SendMessage(const nsAString& aMessageName, return NS_ERROR_DOM_DATA_CLONE_ERR; } + if (data.DataLength() >= kMinTelemetryMessageSize) { + Telemetry::Accumulate(Telemetry::MESSAGE_MANAGER_MESSAGE_SIZE, + NS_ConvertUTF16toUTF8(aMessageName), + data.DataLength()); + } + JS::Rooted objects(aCx); if (aArgc >= 3 && aObjects.isObject()) { objects = &aObjects.toObject(); @@ -810,6 +818,12 @@ nsFrameMessageManager::DispatchAsyncMessage(const nsAString& aMessageName, return NS_ERROR_DOM_DATA_CLONE_ERR; } + if (data.DataLength() >= kMinTelemetryMessageSize) { + Telemetry::Accumulate(Telemetry::MESSAGE_MANAGER_MESSAGE_SIZE, + NS_ConvertUTF16toUTF8(aMessageName), + data.DataLength()); + } + JS::Rooted objects(aCx); if (aArgc >= 3 && aObjects.isObject()) { objects = &aObjects.toObject(); diff --git a/ipc/glue/MessageChannel.cpp b/ipc/glue/MessageChannel.cpp index 4a7f40b26228..ff088587f1b1 100644 --- a/ipc/glue/MessageChannel.cpp +++ b/ipc/glue/MessageChannel.cpp @@ -118,6 +118,8 @@ static MessageChannel* gParentProcessBlocker; namespace mozilla { namespace ipc { +static const int kMinTelemetryMessageSize = 8192; + const int32_t MessageChannel::kNoTimeout = INT32_MIN; // static @@ -749,6 +751,10 @@ MessageChannel::Echo(Message* aMsg) bool MessageChannel::Send(Message* aMsg) { + if (aMsg->size() >= kMinTelemetryMessageSize) { + Telemetry::Accumulate(Telemetry::IPC_MESSAGE_SIZE, nsCString(aMsg->name()), aMsg->size()); + } + CxxStackFrame frame(*this, OUT_MESSAGE, aMsg); nsAutoPtr msg(aMsg); @@ -1045,6 +1051,10 @@ MessageChannel::ProcessPendingRequests(AutoEnterTransaction& aTransaction) bool MessageChannel::Send(Message* aMsg, Message* aReply) { + if (aMsg->size() >= kMinTelemetryMessageSize) { + Telemetry::Accumulate(Telemetry::IPC_MESSAGE_SIZE, nsCString(aMsg->name()), aMsg->size()); + } + nsAutoPtr msg(aMsg); // Sanity checks. diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json index 8c45af145219..dd67b9328768 100644 --- a/toolkit/components/telemetry/Histograms.json +++ b/toolkit/components/telemetry/Histograms.json @@ -10495,5 +10495,25 @@ "kind": "count", "bug_numbers": [1237198], "description": "Count tiny plugin content" + }, + "IPC_MESSAGE_SIZE": { + "alert_emails": ["wmccloskey@mozilla.com"], + "bug_numbers": [1260908], + "expires_in_version": "55", + "kind": "exponential", + "high": 8000000, + "n_buckets": 50, + "keyed": true, + "description": "Measures the size of IPC messages by message name" + }, + "MESSAGE_MANAGER_MESSAGE_SIZE": { + "alert_emails": ["wmccloskey@mozilla.com"], + "bug_numbers": [1260908], + "expires_in_version": "55", + "kind": "exponential", + "high": 8000000, + "n_buckets": 50, + "keyed": true, + "description": "Measures the size of message manager messages by message name" } }