-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Eliminate HTTP2 HPack enumerator allocations #19393
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
src/Servers/Kestrel/Core/src/Internal/Http2/AspNetCoreHPackEncoder.cs
Outdated
Show resolved
Hide resolved
src/Servers/Kestrel/Core/src/Internal/Http2/AspNetCoreHPackEncoder.cs
Outdated
Show resolved
Hide resolved
src/Servers/Kestrel/Core/src/Internal/Http2/AspNetCoreHPackEncoder.cs
Outdated
Show resolved
Hide resolved
src/Servers/Kestrel/Core/src/Internal/Http2/AspNetCoreHPackEncoder.cs
Outdated
Show resolved
Hide resolved
I've changed this PR to use an
|
src/Servers/Kestrel/Core/src/Internal/Http2/Http2HeaderEnumerator.cs
Outdated
Show resolved
Hide resolved
3be08ce
to
ac08759
Compare
src/Servers/Kestrel/Core/src/Internal/Http2/Http2HeaderEnumerator.cs
Outdated
Show resolved
Hide resolved
Yield (current)
Struct enumerator
Class enumerator as IEnumerator
Class enumerator
A cached enumerator on the frame writer and HPackEncoder taking that type directly (avoid interface calls on IEnumerator) is fastest. |
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.
LGTM
Fixes #19275
Creates a shared struct "enumerator" that wraps the two possible struct enumerator types (avoids boxing to
IEnumerator
) and handles enumerating multiple strings inStringValue
(avoids allocation from yield).Long term we should improve the way ASP.NET Core does HPack and try to unify more with the client, but in the meantime this change eliminates 4 allocations per HTTP/2 request.
There are some minor changes to shared HTTP2 code that will need to be mirrored.