Skip to content

Optimize HPACK full match lookup - #706

Merged
arturobernalg merged 1 commit into
apache:masterfrom
arturobernalg:hpack-optimize-full-match-lookup
Sep 28, 2026
Merged

arturobernalg merged 1 commit into
apache:masterfrom
arturobernalg:hpack-optimize-full-match-lookup

Conversation

@arturobernalg

@arturobernalg arturobernalg commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

OutboundDynamicTable#getByName() returns a LinkedList. HPackEncoder#findFullMatch() currently traverses it using indexed access, which causes repeated list traversal.

Using sequential iteration avoids that overhead without changing lookup semantics.

JMH results for a full lookup:

Entries Indexed access Iterator Improvement
32 323.873 ns/op 77.283 ns/op 4.2x
64 707.249 ns/op 119.973 ns/op 5.9x
80 1,087.039 ns/op 196.769 ns/op 5.5x
256 16,100.447 ns/op 852.439 ns/op 18.9x
1,024 354,002.355 ns/op 10,409.408 ns/op 34.0x
4,096 7,779,385.489 ns/op 32,502.873 ns/op 239.3x

The change is limited to replacing indexed traversal with sequential iteration.

@arturobernalg
arturobernalg requested a review from ok2c September 28, 2026 12:51
}
for (int i = 0; i < entries.size(); i++) {
final HPackEntry entry = entries.get(i);
for (final HPackEntry entry : entries) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arturobernalg Does this use Iterator underneath? Can we make it explicit?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this use Iterator underneath? Can we make it explicit?

@ok2c Yes, the enhanced for-loop uses an Iterator underneath. changed

Avoid indexed access when traversing dynamic table entries.
Use sequential iteration for linked lists.
@arturobernalg
arturobernalg force-pushed the hpack-optimize-full-match-lookup branch from 8f09b2b to 8723d60 Compare September 28, 2026 14:07
@arturobernalg
arturobernalg requested a review from ok2c September 28, 2026 14:07
@arturobernalg
arturobernalg merged commit 41f059f into apache:master Sep 28, 2026
12 checks passed
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.

2 participants