Skip to content

Make System.Net.Http.HPack.IntegerDecoder a struct #54209

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

Merged
merged 1 commit into from
Jun 15, 2021

Conversation

teo-tsirpanis
Copy link
Contributor

@teo-tsirpanis teo-tsirpanis commented Jun 15, 2021

Description

System.Net.Http.HPack.IntegerDecoder is a mutable reference type containing two signed 32-bit integers. This PR makes it a struct, eliminating one small allocation per HTTP/2 or 3 connection and providing better locality. On 64-bit platforms the classes that use IntegerDecoder have no size difference while on 32-bit ones they will gain four additional bytes.

If it gets accepted, I will also file a corresponding PR on aspnetcore.

Customer Impact

An allocation of 24/16 bytes per HTTP/2 or 3 connection, on 64/32-bit platforms.

Regression

No

Testing

N/A

Risk

The risk is minimal; there is no behavior change. Future code should be careful to not store IntegerDecoder on a readonly field; existing uses were updated.

@teo-tsirpanis teo-tsirpanis requested a review from a team June 15, 2021 07:40
@ghost ghost added the area-System.Net.Http label Jun 15, 2021
@ghost
Copy link

ghost commented Jun 15, 2021

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

Issue Details

Description

System.Net.Http.HPack.IntegerEncoder is a mutable reference type containing two signed 32-bit integers. This PR makes it a struct, eliminating one small allocation per HTTP/2 or 3 connection and providing better locality. On 64-bit platforms the classes that use IntegerEncoder have no size difference while on 32-bit ones they will gain four additional bytes.

If it gets accepted, I will also file a corresponding PR on aspnetcore.

Customer Impact

An allocation of 24/16 bytes per HTTP/2 or 3 connection, on 64/32-bit platforms.

Regression

No

Testing

N/A

Risk

The risk is minimal; there is no behavior change. Future code should be careful to not store IntegerEncoder on a readonly field; existing uses were updated.

Author: teo-tsirpanis
Assignees: -
Labels:

area-System.Net.Http

Milestone: -

@teo-tsirpanis teo-tsirpanis force-pushed the integer-decoder-struct branch from b808e5b to 6f0e226 Compare June 15, 2021 08:28
@teo-tsirpanis
Copy link
Contributor Author

I see some failures in QUIC tests. Are they related? IntegerDecoder is only used by System.Net.Http and its tests.

@scalablecory scalablecory changed the title Make System.Net.Http.HPack.IntegerEncoder a struct Make System.Net.Http.HPack.IntegerDecoder a struct Jun 15, 2021
Copy link
Contributor

@scalablecory scalablecory left a comment

Choose a reason for hiding this comment

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

lgtm, thanks.

@scalablecory
Copy link
Contributor

CI failures are unrelated.

@scalablecory scalablecory added the tenet-performance Performance related issue label Jun 15, 2021
@scalablecory scalablecory added this to the 6.0.0 milestone Jun 15, 2021
@scalablecory scalablecory merged commit cd8eb2a into dotnet:main Jun 15, 2021
@teo-tsirpanis
Copy link
Contributor Author

Oops, just saw that the commit message has the same typo in IntegerDecoder's name like the title. 😕

wtgodbe pushed a commit to dotnet/aspnetcore that referenced this pull request Jun 15, 2021
@teo-tsirpanis teo-tsirpanis deleted the integer-decoder-struct branch June 16, 2021 08:01
@ghost ghost locked as resolved and limited conversation to collaborators Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants