Bug 1324855 - H2 telemetry for continued header sizes r=hurley r=bsmedberg
authorPatrick McManus <mcmanus@ducksong.com>
Tue, 20 Dec 2016 13:54:15 -0500
changeset 455488 3957966793a4540f45372af9fb891bfdb7580381
parent 455487 2bd53e4e662bcdd32c53cb4e09ceff088e8f6369
child 455489 73c4baa877dd55e8e591e95dd6ece01ccee0689f
push id40256
push userbmo:ntim.bugs@gmail.com
push dateTue, 03 Jan 2017 22:40:23 +0000
reviewershurley, bsmedberg
bugs1324855
milestone53.0a1
Bug 1324855 - H2 telemetry for continued header sizes r=hurley r=bsmedberg
netwerk/protocol/http/Http2Session.cpp
netwerk/protocol/http/Http2Session.h
toolkit/components/telemetry/Histograms.json
--- a/netwerk/protocol/http/Http2Session.cpp
+++ b/netwerk/protocol/http/Http2Session.cpp
@@ -1270,21 +1270,31 @@ Http2Session::RecvHeaders(Http2Session *
 
   // queue up any compression bytes
   self->mDecompressBuffer.Append(&self->mInputFrameBuffer[kFrameHeaderBytes + paddingControlBytes + priorityLen],
                                  self->mInputFrameDataSize - paddingControlBytes - priorityLen - paddingLength);
 
   self->mInputFrameDataStream->UpdateTransportReadEvents(self->mInputFrameDataSize);
   self->mLastDataReadEpoch = self->mLastReadEpoch;
 
+  if (!isContinuation) {
+    self->mAggregatedHeaderSize = self->mInputFrameDataSize - paddingControlBytes - priorityLen - paddingLength;
+  } else {
+    self->mAggregatedHeaderSize += self->mInputFrameDataSize - paddingControlBytes - priorityLen - paddingLength;
+  }
+
   if (!endHeadersFlag) { // more are coming - don't process yet
     self->ResetDownstreamState();
     return NS_OK;
   }
 
+  if (isContinuation) {
+    Telemetry::Accumulate(Telemetry::SPDY_CONTINUED_HEADERS, self->mAggregatedHeaderSize);
+  }
+
   rv = self->ResponseHeadersComplete();
   if (rv == NS_ERROR_ILLEGAL_VALUE) {
     LOG3(("Http2Session::RecvHeaders %p PROTOCOL_ERROR detected stream 0x%X\n",
           self, self->mInputFrameID));
     self->CleanupStream(self->mInputFrameDataStream, rv, PROTOCOL_ERROR);
     self->ResetDownstreamState();
     rv = NS_OK;
   } else if (NS_FAILED(rv)) {
@@ -1668,22 +1678,32 @@ Http2Session::RecvPushPromise(Http2Sessi
     }
     self->ResetDownstreamState();
     return NS_OK;
   }
 
   self->mDecompressBuffer.Append(&self->mInputFrameBuffer[kFrameHeaderBytes + paddingControlBytes + promiseLen],
                                  self->mInputFrameDataSize - paddingControlBytes - promiseLen - paddingLength);
 
+  if (self->mInputFrameType != FRAME_TYPE_CONTINUATION) {
+    self->mAggregatedHeaderSize = self->mInputFrameDataSize - paddingControlBytes - promiseLen - paddingLength;
+  } else {
+    self->mAggregatedHeaderSize += self->mInputFrameDataSize - paddingControlBytes - promiseLen - paddingLength;
+  }
+
   if (!(self->mInputFrameFlags & kFlag_END_PUSH_PROMISE)) {
     LOG3(("Http2Session::RecvPushPromise not finishing processing for multi-frame push\n"));
     self->ResetDownstreamState();
     return NS_OK;
   }
 
+  if (self->mInputFrameType == FRAME_TYPE_CONTINUATION) {
+    Telemetry::Accumulate(Telemetry::SPDY_CONTINUED_HEADERS, self->mAggregatedHeaderSize);
+  }
+
   // Create the buffering transaction and push stream
   RefPtr<Http2PushTransactionBuffer> transactionBuffer =
     new Http2PushTransactionBuffer();
   transactionBuffer->SetConnection(self);
   Http2PushedStream *pushedStream =
     new Http2PushedStream(transactionBuffer, self, associatedStream, promisedID);
 
   rv = pushedStream->ConvertPushHeaders(&self->mDecompressor,
--- a/netwerk/protocol/http/Http2Session.h
+++ b/netwerk/protocol/http/Http2Session.h
@@ -478,16 +478,19 @@ private:
   // used as a temporary buffer while enumerating the stream hash during GoAway
   nsDeque  mGoAwayStreamsToRestart;
 
   // Each session gets a unique serial number because the push cache is correlated
   // by the load group and the serial number can be used as part of the cache key
   // to make sure streams aren't shared across sessions.
   uint64_t        mSerial;
 
+  // Telemetry for continued headers (pushed and pulled) for quic design
+  uint32_t        mAggregatedHeaderSize;
+
   // If push is disabled, we want to be able to send PROTOCOL_ERRORs if we
   // receive a PUSH_PROMISE, but we have to wait for the SETTINGS ACK before
   // we can actually tell the other end to go away. These help us keep track
   // of that state so we can behave appropriately.
   bool mWaitingForSettingsAck;
   bool mGoAwayOnPush;
 
   bool mUseH2Deps;
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -2319,16 +2319,25 @@
     "description": "H2: goaway reason client sent from rfc 7540. 31 is none sent."
   },
   "SPDY_GOAWAY_PEER": {
     "expires_in_version": "never",
     "kind": "enumerated",
     "n_values": 32,
     "description": "H2: goaway reason from peer from rfc 7540. 31 is none received."
   },
+  "SPDY_CONTINUED_HEADERS": {
+    "expires_in_version": "59",
+    "alert_emails": ["necko@mozilla.com"],
+    "bug_numbers": [1324855],
+    "kind": "exponential",
+    "high": 32000000,
+    "n_buckets": 75,
+    "description": "Size of continued H2 headers in bytes."
+  },
   "HPACK_ELEMENTS_EVICTED_DECOMPRESSOR": {
     "expires_in_version": "never",
     "kind": "exponential",
     "high": 256,
     "n_buckets": 50,
     "description": "HPACK: Number of items removed from dynamic table to make room for 1 new item",
     "alert_emails": ["necko@mozilla.com", "hurley@mozilla.com"],
     "bug_numbers": [1296280]