KEMBAR78
Avoid allocations in 'Transfer-Encoding: Chunked' check by MihaZupan · Pull Request #81253 · dotnet/runtime · GitHub
Skip to content

Conversation

MihaZupan
Copy link
Member

Fixes #63052

Avoids 3 object allocations: TransferCodingHeaderValue, HeaderStoreItemInfo, and "chunked" (100 bytes total).
This is ~4 % of allocated bytes for a simple YARP request.

Before:
image

After:
image

@MihaZupan MihaZupan added this to the 8.0.0 milestone Jan 27, 2023
@MihaZupan MihaZupan self-assigned this Jan 27, 2023
@ghost
Copy link

ghost commented Jan 27, 2023

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

Fixes #63052

Avoids 3 object allocations: TransferCodingHeaderValue, HeaderStoreItemInfo, and "chunked" (100 bytes total).
This is ~4 % of allocated bytes for a simple YARP request.

Before:
image

After:
image

Author: MihaZupan
Assignees: MihaZupan
Labels:

area-System.Net.Http

Milestone: 8.0.0

return true;
}

if (parent.ContainsParsedValue(KnownHeaders.TransferEncoding.Descriptor, HeaderUtilities.TransferEncodingChunked))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does ContainsParsedValue perform any other side-effects that this now skips?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not as it's currently written - if the value is just "chunked", then that's exactly what you would have seen from non-validated or validated accesses later on anyway.

If we tried being smarter with the above check, e.g. "parse all the values without allocating and look for chunked", then you could introduce subtle differences where a non-validating access would still see the original, non-parsed value. But that is also the whole point of NonValidated so it'd be even more correct IMO.

@MihaZupan
Copy link
Member Author

Build failure is known according to Build Analysis

@MihaZupan MihaZupan merged commit d2eed6c into dotnet:main Jan 27, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Feb 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve efficiency of parsing of Transfer-Encoding: chunked on HTTP/1.1 response

2 participants