Performance optimizations for parsers#148
Open
benoitc wants to merge 3 commits into
Open
Conversation
Use skip/len tracking instead of byte-by-byte binary accumulation in parse_hd_value. This avoids O(n²) allocation overhead. Key changes: - Track original binary + skip position + length - Add 4-byte chunking for faster scanning - Separate fast path for single-segment vs folded headers - Use binary:part/3 only at boundaries Benchmark shows ~2.1x speedup for typical header blocks.
Add map-based indices for O(1) header lookup during encoding. Previously, finding a header in the dynamic table required O(n) linear scan. Now uses maps with sequence numbers. Key changes: - Add dyn_field_idx and dyn_name_idx maps to state record - Store sequence numbers; compute actual index via maps:size - Insert without eviction is O(1) (no map shifting needed) - Rebuild maps only on eviction (less frequent operation) - Add bench/0 for performance testing Lookup formula: index = 62 + (count - 1 - seq) Benchmark: 0.036 us/lookup with 50 dynamic entries.
Add map-based indices for O(1) header lookup during encoding, similar to the HPACK optimization. Key changes: - Add dyn_field_idx and dyn_name_idx maps to state record - Store absolute indices (which never change in QPACK) - Insert without eviction is O(1) - Rebuild maps only on eviction - Add bench/0 for performance testing Benchmark: 0.037 us/lookup with 50 dynamic entries.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Results
All tests pass.