-
Notifications
You must be signed in to change notification settings - Fork 4.6k
mem: Add faster tiered buffer pool #8775
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
base: master
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #8775 +/- ##
==========================================
+ Coverage 83.22% 83.45% +0.22%
==========================================
Files 418 419 +1
Lines 32385 32642 +257
==========================================
+ Hits 26952 27240 +288
+ Misses 4050 4026 -24
+ Partials 1383 1376 -7
🚀 New features to boost your workflow:
|
bdccc9b to
1f26e66
Compare
easwars
left a comment
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.
I thought we decided to make it possible for the user to set the default buffer pool for the whole process through an experimental API, and get rid of the existing dial option and the server option. Was your plan to do that in a follow-up?
|
|
||
| // Determine the maximum exponent we need to support. | ||
| // bits.Len64(math.MaxUint64) is 63. | ||
| const maxExponent = 63 |
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.
Does this assume a 64-bit machine?
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.
It works for machines up to 64 bits, i.e. both 32 and 64 bits.
mem/buffer_pool.go
Outdated
| if exp > maxExponent || exp < 0 { | ||
| continue | ||
| } |
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.
Are we silently ignoring certain exponents that don't meet our criteria? Should we error out instead?
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.
Added a comment explaining the reason to ignore the values.
- For values greater than 63, it's not possible to allocate such large slices. So ignoring them will not cause observable changes. I changed the param type to
uint8to help give linter errors if people pass constant values > 256. - For values < 1, the buffer sizes would be fractional, e.g.
$2^{-1}=0.5$ . Since slices are of integer sizes, a sized buffer pool with a fractional size will never get used. I changed the param type touint, making it impossible to pass negative values.
I was waiting for the author of #8770 to raise a PR for exposing a function to set the default buffer pool. See the second part of #8770 (comment).
I'm not sure if we want to do this. Maybe people want to use different buffer pools for each channel. In this PR, I'm just improving the existing buffer pool implementation. |
b50277e to
8e7ecc4
Compare
8e7ecc4 to
36d34f7
Compare
This change adds a new tiered buffer pool that uses power-of-2 tier sizes. It reduces the lookup time for the relevant sizedBufferPool from$O(\log n)$ to $O(1)$ , where n is the number of tiers. This creates constant-time lookups independent of the tier count, allowing users to add more tiers without performance overhead.
Benchmarks
Micro-benchmark that measures only the pool query performance, ignoring the allocation time:
With 5 tiers:
With 9 tiers:
RELEASE NOTES:
NewBinaryTieredBufferPoolto create such pools.