Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

header.go Referer() optimize #1313

Merged
merged 3 commits into from Jun 6, 2022
Merged

Conversation

stokito
Copy link
Contributor

@stokito stokito commented Jun 5, 2022

small improvements

This should be optimized by Go compiler itself so the b2s() call is not needed.

It was previously done by this but changed in
1e7885e
Use direct peekArgBytes() instead of PeekBytes() that will check for special headers
The old BenchmarkRequestHeaderPeekBytesCanonical and BenchmarkRequestHeaderPeekBytesNonCanonical are in fact just measured the header normalization.
But it's anyway is benchmarked separately.
Results was almost the same: 1.5 ns/op.

Instead, let's reuse the benches to find a difference between peeking of special (Host, CT) and custom headers.
@erikdubbelboer erikdubbelboer merged commit 66cd502 into valyala:master Jun 6, 2022
@erikdubbelboer
Copy link
Collaborator

Thanks!

@stokito stokito deleted the header_peek branch June 6, 2022 07:33
bbenzikry pushed a commit to bbenzikry/fasthttp that referenced this pull request Sep 11, 2022
* args.go GetBool(): use switch with string casting

This should be optimized by Go compiler itself so the b2s() call is not needed.

It was previously done by this but changed in
1e7885e

* header.go Referer() optimize

Use direct peekArgBytes() instead of PeekBytes() that will check for special headers

* header_timing_test.go BenchmarkRequestHeaderPeekBytesSpecialHeader

The old BenchmarkRequestHeaderPeekBytesCanonical and BenchmarkRequestHeaderPeekBytesNonCanonical are in fact just measured the header normalization.
But it's anyway is benchmarked separately.
Results was almost the same: 1.5 ns/op.

Instead, let's reuse the benches to find a difference between peeking of special (Host, CT) and custom headers.
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.

None yet

2 participants