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
Replace pool with bytes in readLoop #2758
Conversation
Replace pool with bytes in readLoop
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2758 +/- ##
==========================================
- Coverage 78.63% 78.60% -0.04%
==========================================
Files 87 87
Lines 8202 8198 -4
==========================================
- Hits 6450 6444 -6
- Misses 1279 1281 +2
Partials 473 473
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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!
@cnderrauber Would you mind explaining the reasoning for the change? Does this reduce allocation for a single data channel? What is the impact if the user has many? The original change was driven with data. Would be nice to match that! |
@Sean-Der It does not revert the change 159ba5a but a simplify, the oldest behavior was allocating a 65KB buffer for each read call, then @bshimc change it to get buffer from pool for every loop, but we don't need a pool here if the readLoop always need a bytes buffer, just allocate it once at the head and release it at end |
|
The reason that the pool is required is that, under high concurrency and GC pressure, memory allocation explodes and performance is crippled. From the 159ba5a - note how allocations/op stays constant as parallelism increases (and goes to 0 with a pooled approach). Note also how time/op stays relatively constant because GC pressure has been alleviated. Two things to note about the the most recent benchmark numbers in the previous comment are;
I would recommend rolling back this change and profiling to figure out where this regression came from (or perhaps just bisect and benchmark for a quick search). Instead of eliminating pooling, I suspect the team needs to increase the use of pools. CC @Sean-Der |
This is different with code before 1516, the problem of the original code is it allocates 65KB bytes in every read that cause the gc pressure, and this change allocates the buffer only once for a data channel readloop and reuse it for in the entire channel lifecycle, I don't think the data channel creation is a high frequency operation that needs a pool for it. |
Replace pool with bytes in readLoop
Description
Reference issue
Fixes #...