Bug 1014600 part 1 - Improve HPACK logging. r=mcmanus
authorNicholas Hurley <hurley@todesschaf.org>
Fri, 11 Jul 2014 09:48:32 -0700
changeset 193620 e28d922d5d1735954b4f2108ea63ca0ed038df2d
parent 193619 d257e3805fc79aaf1c023144881ff3d9527c6611
child 193621 9ded0b5313b40c3e95e38a9c5067f69431218a06
push id27123
push userryanvm@gmail.com
push dateFri, 11 Jul 2014 20:35:05 +0000
treeherdermozilla-central@84bd8d9f4256 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus
bugs1014600
milestone33.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 1014600 part 1 - Improve HPACK logging. r=mcmanus
netwerk/protocol/http/Http2Compression.cpp
--- a/netwerk/protocol/http/Http2Compression.cpp
+++ b/netwerk/protocol/http/Http2Compression.cpp
@@ -293,20 +293,22 @@ Http2BaseCompressor::DumpState()
 
   LOG(("Reference Set"));
   length = mReferenceSet.Length();
   for (i = 0; i < length; ++i) {
     LOG(("index %u: %u", i, mReferenceSet[i]));
   }
 
   LOG(("Header Table"));
-  length = mHeaderTable.VariableLength();
+  length = mHeaderTable.Length();
+  uint32_t variableLength = mHeaderTable.VariableLength();
   for (i = 0; i < length; ++i) {
     const nvPair *pair = mHeaderTable[i];
-    LOG(("index %u: %s %s", i, pair->mName.get(), pair->mValue.get()));
+    LOG(("%sindex %u: %s %s", i < variableLength ? "" : "static ", i,
+         pair->mName.get(), pair->mValue.get()));
   }
 }
 
 nsresult
 Http2Decompressor::DecodeHeaderBlock(const uint8_t *data, uint32_t datalen,
                                      nsACString &output)
 {
   mAlternateReferenceSet.Clear();
@@ -506,18 +508,20 @@ Http2Decompressor::OutputHeader(const ns
   mOutput->AppendLiteral("\r\n");
   return NS_OK;
 }
 
 nsresult
 Http2Decompressor::OutputHeader(uint32_t index)
 {
   // bounds check
-  if (mHeaderTable.Length() <= index)
+  if (mHeaderTable.Length() <= index) {
+    LOG(("Http2Decompressor::OutputHeader index too large %u", index));
     return NS_ERROR_ILLEGAL_VALUE;
+  }
 
   return OutputHeader(mHeaderTable[index]->mName,
                       mHeaderTable[index]->mValue);
 }
 
 nsresult
 Http2Decompressor::CopyHeaderString(uint32_t index, nsACString &name)
 {
@@ -713,20 +717,21 @@ Http2Decompressor::CopyHuffmanStringFrom
 
 void
 Http2Decompressor::MakeRoom(uint32_t amount)
 {
   // make room in the header table
   uint32_t removedCount = 0;
   while (mHeaderTable.VariableLength() && ((mHeaderTable.ByteCount() + amount) > mMaxBuffer)) {
     uint32_t index = mHeaderTable.VariableLength() - 1;
+    LOG(("HTTP decompressor header table index %u %s %s removed for size.\n",
+         index, mHeaderTable[index]->mName.get(),
+         mHeaderTable[index]->mValue.get()));
     mHeaderTable.RemoveElement();
     ++removedCount;
-    LOG(("HTTP decompressor header table index %u removed for size.\n",
-         index));
   }
 
   // adjust references to header table
   UpdateReferenceSet(removedCount);
 }
 
 nsresult
 Http2Decompressor::DoIndexed()
@@ -767,16 +772,18 @@ Http2Decompressor::DoIndexed()
       ClearHeaderTable();
       LOG(("HTTP decompressor index not referenced due to size %u %s %s\n",
            room, pair->mName.get(), pair->mValue.get()));
       LOG(("Decompressor state after ClearHeaderTable"));
       DumpState();
       return rv;
     }
 
+    LOG(("HTTP decompressor inserting static entry %u %s %s into dynamic table",
+         index, pair->mName.get(), pair->mValue.get()));
     MakeRoom(room);
     mHeaderTable.AddElement(pair->mName, pair->mValue);
     IncrementReferenceSetIndices();
     index = 0;
   }
 
   mReferenceSet.AppendElement(index);
   mAlternateReferenceSet.AppendElement(index);
@@ -807,19 +814,23 @@ Http2Decompressor::DoLiteralInternal(nsA
     rv = DecodeInteger(7, nameLen);
     if (NS_SUCCEEDED(rv)) {
       if (isHuffmanEncoded) {
         rv = CopyHuffmanStringFromInput(nameLen, name);
       } else {
         rv = CopyStringFromInput(nameLen, name);
       }
     }
+    LOG(("Http2Decompressor::DoLiteralInternal literal name %s",
+         name.BeginReading()));
   } else {
     // name is from headertable
     rv = CopyHeaderString(index - 1, name);
+    LOG(("Http2Decompressor::DoLiteralInternal indexed name %d %s",
+         index, name.BeginReading()));
   }
   if (NS_FAILED(rv))
     return rv;
 
   // now the value
   uint32_t valueLen;
   isHuffmanEncoded = mData[mOffset] & (1 << 7);
   rv = DecodeInteger(7, valueLen);
@@ -827,16 +838,17 @@ Http2Decompressor::DoLiteralInternal(nsA
     if (isHuffmanEncoded) {
       rv = CopyHuffmanStringFromInput(valueLen, value);
     } else {
       rv = CopyStringFromInput(valueLen, value);
     }
   }
   if (NS_FAILED(rv))
     return rv;
+  LOG(("Http2Decompressor::DoLiteralInternal value %s", value.BeginReading()));
   return NS_OK;
 }
 
 nsresult
 Http2Decompressor::DoLiteralWithoutIndex()
 {
   // this starts with 0000 bit pattern
   MOZ_ASSERT((mData[mOffset] & 0xF0) == 0x00);
@@ -1309,75 +1321,62 @@ Http2Compressor::HuffmanAppend(const nsC
   uint32_t length = value.Length();
   uint32_t offset;
   uint8_t *startByte;
 
   for (uint32_t i = 0; i < length; ++i) {
     uint8_t idx = static_cast<uint8_t>(value[i]);
     uint8_t huffLength = HuffmanOutgoing[idx].mLength;
     uint32_t huffValue = HuffmanOutgoing[idx].mValue;
-    LOG(("Http2Compressor::HuffmanAppend %p character=%c (%d) value=%X "
-         "length=%d offset=%d bitsLeft=%d\n", this, value[i], idx, huffValue,
-         huffLength, offset, bitsLeft));
 
     if (bitsLeft < 8) {
       // Fill in the least significant <bitsLeft> bits of the previous byte
       // first
       uint32_t val;
       if (huffLength >= bitsLeft) {
         val = huffValue & ~((1 << (huffLength - bitsLeft)) - 1);
         val >>= (huffLength - bitsLeft);
       } else {
         val = huffValue << (bitsLeft - huffLength);
       }
       val &= ((1 << bitsLeft) - 1);
       offset = buf.Length() - 1;
-      LOG(("Http2Compressor::HuffmanAppend %p appending %X to byte %d.",
-           this, val, offset));
       startByte = reinterpret_cast<unsigned char *>(buf.BeginWriting()) + offset;
       *startByte = *startByte | static_cast<uint8_t>(val & 0xFF);
       if (huffLength >= bitsLeft) {
         huffLength -= bitsLeft;
         bitsLeft = 8;
       } else {
         bitsLeft -= huffLength;
         huffLength = 0;
       }
-      LOG(("Http2Compressor::HuffmanAppend %p encoded length remaining=%d, "
-           "bitsLeft=%d\n", this, huffLength, bitsLeft));
     }
 
     while (huffLength >= 8) {
       uint32_t mask = ~((1 << (huffLength - 8)) - 1);
       uint8_t val = ((huffValue & mask) >> (huffLength - 8)) & 0xFF;
       buf.Append(reinterpret_cast<char *>(&val), 1);
       huffLength -= 8;
-      LOG(("Http2Compressor::HuffmanAppend %p appended byte %X, encoded "
-           "length remaining=%d\n", this, val, huffLength));
     }
 
     if (huffLength) {
       // Fill in the most significant <huffLength> bits of the next byte
       bitsLeft = 8 - huffLength;
       uint8_t val = (huffValue & ((1 << huffLength) - 1)) << bitsLeft;
       buf.Append(reinterpret_cast<char *>(&val), 1);
-      LOG(("Http2Compressor::HuffmanAppend %p setting high %d bits of last "
-           "byte to %X. bitsLeft=%d.\n", this, huffLength, val, bitsLeft));
     }
   }
 
   if (bitsLeft != 8) {
     // Pad the last <bitsLeft> bits with ones, which corresponds to the EOS
     // encoding
     uint8_t val = (1 << bitsLeft) - 1;
     offset = buf.Length() - 1;
     startByte = reinterpret_cast<unsigned char *>(buf.BeginWriting()) + offset;
     *startByte = *startByte | val;
-    LOG(("Http2Compressor::HuffmanAppend %p padded low %d bits of last byte "
-         "with %X", this, bitsLeft, val));
   }
 
   // Now we know how long our encoded string is, we can fill in our length
   uint32_t bufLength = buf.Length();
   offset = mOutput->Length();
   EncodeInteger(7, bufLength);
   startByte = reinterpret_cast<unsigned char *>(mOutput->BeginWriting()) + offset;
   *startByte = *startByte | 0x80;