Bug 1264662 - Record IPC message capacity instead of size. r=billm, a=ritu
authorAndrew McCreight <continuation@gmail.com>
Thu, 14 Apr 2016 17:46:52 -0700
changeset 323992 73554a815d7c3ae9ba4b61ead297fb3bb7ba7b27
parent 323991 29e500802b47d41effd9755787a5f31d18d79c1c
child 323993 a6a267e0ce6c08f7af8393d522b92c2a2a4ba14e
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm, ritu
bugs1264662
milestone47.0a2
Bug 1264662 - Record IPC message capacity instead of size. r=billm, a=ritu Capacity includes internal fragmentation, while size does not. This requires making capacity() public, but that seems benign.
ipc/chromium/src/base/pickle.h
ipc/glue/MessageChannel.cpp
--- a/ipc/chromium/src/base/pickle.h
+++ b/ipc/chromium/src/base/pickle.h
@@ -57,16 +57,21 @@ class Pickle {
   Pickle& operator=(const Pickle& other);
 
   Pickle& operator=(Pickle&& other);
 
   // Returns the size of the Pickle's data.
   int size() const { return static_cast<int>(header_size_ +
                                              header_->payload_size); }
 
+  // Return the full size of the memory allocated for this Pickle's data.
+  uint32_t capacity() const {
+    return capacity_;
+  }
+
   // Returns the data for this Pickle.
   const void* data() const { return header_; }
 
   // Methods for reading the payload of the Pickle.  To read from the start of
   // the Pickle, initialize *iter to NULL.  If successful, these methods return
   // true.  Otherwise, false is returned to indicate that the result could not
   // be extracted.
   MOZ_WARN_UNUSED_RESULT bool ReadBool(void** iter, bool* result) const;
@@ -229,20 +234,16 @@ class Pickle {
     // We must have a valid header_.
     return payload() + payload_size();
   }
   const char* end_of_payload() const {
     // This object may be invalid.
     return header_ ? payload() + payload_size() : nullptr;
   }
 
-  uint32_t capacity() const {
-    return capacity_;
-  }
-
   // Resizes the buffer for use when writing the specified amount of data. The
   // location that the data should be written at is returned, or NULL if there
   // was an error. Call EndWrite with the returned offset and the given length
   // to pad out for the next write.
   char* BeginWrite(uint32_t length, uint32_t alignment);
 
   // Completes the write operation by padding the data with NULL bytes until it
   // is padded. Should be paired with BeginWrite, but it does not necessarily
--- a/ipc/glue/MessageChannel.cpp
+++ b/ipc/glue/MessageChannel.cpp
@@ -113,17 +113,17 @@ struct RunnableMethodTraits<mozilla::ipc
             DebugAbort(__FILE__, __LINE__, #_cond,## __VA_ARGS__);  \
     } while (0)
 
 static MessageChannel* gParentProcessBlocker;
 
 namespace mozilla {
 namespace ipc {
 
-static const int kMinTelemetryMessageSize = 8192;
+static const uint32_t kMinTelemetryMessageSize = 8192;
 
 const int32_t MessageChannel::kNoTimeout = INT32_MIN;
 
 // static
 bool MessageChannel::sIsPumpingMessages = false;
 
 enum Direction
 {
@@ -746,18 +746,19 @@ 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, nsCString(aMsg->name()), aMsg->size());
+    if (aMsg->capacity() >= kMinTelemetryMessageSize) {
+        Telemetry::Accumulate(Telemetry::IPC_MESSAGE_SIZE,
+                              nsCString(aMsg->name()), aMsg->capacity());
     }
 
     CxxStackFrame frame(*this, OUT_MESSAGE, aMsg);
 
     nsAutoPtr<Message> msg(aMsg);
     AssertWorkerThread();
     mMonitor->AssertNotCurrentThreadOwns();
     if (MSG_ROUTING_NONE == msg->routing_id()) {
@@ -1034,18 +1035,19 @@ MessageChannel::ProcessPendingRequests(A
             ProcessPendingRequest(*it);
         }
     }
 }
 
 bool
 MessageChannel::Send(Message* aMsg, Message* aReply)
 {
-    if (aMsg->size() >= kMinTelemetryMessageSize) {
-        Telemetry::Accumulate(Telemetry::IPC_MESSAGE_SIZE, nsCString(aMsg->name()), aMsg->size());
+    if (aMsg->capacity() >= kMinTelemetryMessageSize) {
+        Telemetry::Accumulate(Telemetry::IPC_MESSAGE_SIZE,
+                              nsCString(aMsg->name()), aMsg->capacity());
     }
 
     nsAutoPtr<Message> msg(aMsg);
 
     // Sanity checks.
     AssertWorkerThread();
     mMonitor->AssertNotCurrentThreadOwns();