Speed up Balsa HTTP/1 token validation#45186
Open
benni-rogge wants to merge 1 commit into
Open
Conversation
Signed-off-by: Benni Rogge <benni.rogge@shopify.com>
|
Hi @benni-rogge, welcome and thank you for your contribution. We will try to review your Pull Request as quickly as possible. In the meantime, please take a look at the contribution guidelines if you have not done so already. |
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.
Commit Message:
Speed up Balsa HTTP/1 token validation
Additional Description:
Replace the per-character binary search used for Balsa HTTP/1 token validation with a constexpr bit mask. Header field names and custom methods still use the RFC 9110 token character set, but the hot path now does a fixed-index mask lookup for each byte.
Testing:
bazel test -c opt //test/common/http/http1:balsa_parser_test //test/common/http/http1:balsa_parser_benchmark_test //test/common/http/http1:codec_impl_testgit diff --checkBenchmark:
Command used for both baseline and optimized runs:
bazel run -c opt //test/common/http/http1:balsa_parser_benchmark -- --benchmark_filter=bmParseHeaders --benchmark_min_time=0.25s --benchmark_repetitions=10 --benchmark_out=<file>.json --benchmark_out_format=json1724.6 ns1051.0 ns39.06%37.59%..40.52%3238.2 ns1832.0 ns43.42%42.81%..44.03%12156.5 ns6246.1 ns48.62%47.04%..50.20%47039.9 ns24059.3 ns48.85%48.25%..49.46%97201.0 ns48013.2 ns50.60%49.46%..51.75%531.1 ns497.9 ns6.26%5.38%..7.14%850.9 ns744.9 ns12.46%11.61%..13.31%2540.0 ns2066.9 ns18.62%17.76%..19.48%9711.9 ns7381.7 ns23.99%23.50%..24.49%19393.7 ns14645.0 ns24.49%23.91%..25.06%4054.1 ns1984.0 ns51.06%49.85%..52.27%7796.9 ns3646.6 ns53.23%52.41%..54.05%29938.3 ns13281.4 ns55.64%55.13%..56.15%120034.2 ns51514.2 ns57.08%56.45%..57.72%240048.1 ns102724.5 ns57.21%56.72%..57.70%