-
Notifications
You must be signed in to change notification settings - Fork 84
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
Reduce allocs in HTTP2StreamChannel #449
Conversation
It would be useful to get an idea of whether there's any significant performance impact to this change. I suspect that for most applications it comes out about neutral, but I'm not sure. |
This will obviously depend on how frequently A concrete example is AHC which uses it a few times per request (in channel active and when writability changes). I used it to benchmark against httpbin (running locally) and the difference was negligible. |
You'll need to update the allocations for main too |
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.
As the change is low risk and easily reverted, I'm fine with it.
Motivation: The HTTP2StreamChannel stores two atomic booleans for whether the channel is active and writable. These are only accessed externally and access is relatively infrequent. Each atomic requires an allocation, instead we can just protect each with a single lock. Modifications: - Combine the two atomics into a single 'flags' struct protected by a locked value box Result: Fewer alloations
Motivation:
The HTTP2StreamChannel stores two atomic booleans for whether the channel is active and writable. These are only accessed externally and access is relatively infrequent. Each atomic requires an allocation, instead we can just protect each with a single lock.
Modifications:
Result:
Fewer alloations