-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Add ValueTask pooling in more places #68457
Conversation
- Use ValueTask pooling on StreamPipeReader.ReadAsync and ReadAtLeastAsync and StreamPipeWriter.FlushAsync
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.
Have you validated impact on throughput (and not just that allocation numbers are reduced) in expected use?
Will run benchmarks on a few profiles and report back. |
Updated the description. |
Thanks for the data. I can't tell from the numbers shared; did this help? hurt? nop? The code changes themselves in the PR look fine; If we believe this truly helps for more than just removing some lines from an allocation profile, then go ahead. I want to reiterate for the record though that we do need to be thoughtful with this pooling. We added the support for good reason, and there are absolutely valid times to use it, we just need to be careful about it as there can be hidden costs. For example, pooling can easily create more references from pooled Gen2 objects to newer/temporary Gen0 objects, which in turn makes GCs slower when they occur and thus actually negatively impact performance / P99 latency rather than helping it. |
It doesn't hurt the RPS, in this scenario its slightly better (though that might be noise). Yes, I'm aware of the downsides 😄. |
Improvements: dotnet/perf-autofiling-issues#5095 |
That doesn't seem right. This PR would help with System.IO.Pipelines, but I don't believe those tests rely on pipelines in any way. |
Looks more like #59110 would have this affect, also has perf numbers that look similar #59110 (comment) |
Fixes #30169 and contributes to dotnet/aspnetcore#41343
Here's the allocation profile for the JSON https benchmark:
Crank command line:
Crank with allocation profile:
Before
You can see the top allocation is the StreamPipeReader state machine. Here are the client stats:
After
Allocation profile