Skip to content

Decode HPACK Huffman string literals a byte at a time - #1255

Open
arturobernalg wants to merge 1 commit into
apache:mainfrom
arturobernalg:hpack-huffman-byte-table
Open

arturobernalg wants to merge 1 commit into
apache:mainfrom
arturobernalg:hpack-huffman-byte-table

Conversation

@arturobernalg

Copy link
Copy Markdown
Member

HPackHuffman.decode walks the code tree one bit at a time. Profiling Tomcat under HTTP/2 load with the JDK HttpClient (which sends header values as Huffman literals on every request rather than indexing them) showed about 26% of server CPU in this method.

This replaces the tree walk with a table indexed by eight bits of input, as other HPACK implementations do.

  • Decoding is about 3x faster (the common request header values: 2.8 us -> 0.9 us; short :path values about 2x).
    • Results are identical to the current decoder, including which of the three RFC 7541 5.2 errors is raised, over 1.5M random and malformed inputs.
    • h2c, 1 KB static resource, server pinned to two cores: +12% requests/s, -12% CPU per request with the JDK client. With a client that indexes headers (curl/nghttp2) only :path is Huffman decoded per request, so there is no measurable end-to-end difference.
      Added tests for the Huffman literals in the RFC 7541 appendix C examples and for the decoding errors. The HTTP/2 tests and the smoke profile pass.

Replace the bit-at-a-time tree walk with a table indexed by eight bits of
input, as other HPACK implementations do. Decoding is about three times
faster with identical results, including the three decoding errors
required by RFC 7541, section 5.2.

Add tests for the Huffman encoded literals in the RFC 7541 examples and
for the decoding errors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant