Skip to content

perf: optimize HPACK decoding with 8-bit tables - #926

Open
seanmonstar wants to merge 2 commits into
masterfrom
sean/yxowmrxxmzor
Open

perf: optimize HPACK decoding with 8-bit tables#926
seanmonstar wants to merge 2 commits into
masterfrom
sean/yxowmrxxmzor

Conversation

@seanmonstar

Copy link
Copy Markdown
Member

Previously we used a table of nibbles to each state of decoding. Instead, we now use a few byte-wide tables. Common codes fit in the first table, rarer codes are completed looking in the next tables.

On my low powered machine, these are the bench results:

Before:

test hpack::huffman::bench::decode_all_octets   ... bench:       5,476.74 ns/iter (+/- 567.07) = 106 MB/s
test hpack::huffman::bench::decode_header_value ... bench:         765.42 ns/iter (+/- 145.32) = 62 MB/s
test hpack::huffman::bench::decode_long_ascii   ... bench:         905.51 ns/iter (+/- 161.67) = 66 MB/s
test hpack::huffman::bench::decode_short_ascii  ... bench:         172.34 ns/iter (+/- 34.22) = 69 MB/s

After:

test hpack::huffman::bench::decode_all_octets   ... bench:       3,887.27 ns/iter (+/- 678.71) = 149 MB/s
test hpack::huffman::bench::decode_header_value ... bench:         661.78 ns/iter (+/- 88.98) = 72 MB/s
test hpack::huffman::bench::decode_long_ascii   ... bench:         724.07 ns/iter (+/- 93.60) = 82 MB/s
test hpack::huffman::bench::decode_short_ascii  ... bench:         152.48 ns/iter (+/- 13.02) = 78 MB/s

Which is about 13-41% improvement, depending.

cc #883

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