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

stokito added 3 commits Jun 5, 2022
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
14 checks passed
@erikdubbelboer
Copy link
Collaborator

erikdubbelboer commented Jun 6, 2022

Thanks!

@stokito stokito deleted the header_peek branch Jun 6, 2022
bbenzikry pushed a commit to bbenzikry/fasthttp that referenced this issue 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