-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Remove array allocation from multi-span header parsing #45044
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
Conversation
|
I was able to improve Edit: Cleaned it up a bit so it's not too bad |
halter73
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
| } | ||
|
|
||
| [Benchmark(OperationsPerInvoke = RequestParsingData.InnerLoopCount)] | ||
| public void MultispanUnicodeHeader() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add this to https://aka.ms/aspnet/benchmarks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noticed this allocation while looking at a memory profile for CertAuth. My hypothesis is that the certificate/tls handshake is pushing the header bytes across a PipeSegment boundary which goes through the multi-span header parsing path, and that path would allocate a
byte[]if the header crossed multiple spans. This change avoids the allocation by usingstackallocorArrayPool<byte>.Shared.The highlighted line is now gone from the benchmark 😃
Before:
After:
The Op/s difference is noise, especially since
Unicodeshouldn't hit the changed code path.