-
Notifications
You must be signed in to change notification settings - Fork 4.6k
mem: Allocate at 4KiB boundaries in the fallback buffer pool. #8705
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
By rounding up to the nearest page, we avoid repeatedly allocating similar sizes if requests happen to arrive in roughly increasing order. The GCS client repeatedly sends messages with 2MiB of data when writing a large object. Therefore it has to repeatedly allocate just over 2MiB. This ultimately results in many, many allocations in the fallback buffer pool. In practice this yields at least a 10x reduction in RAM when running 100 concurrent large writes. This is probably not unique to GCS: anyone who sends large messages may be affected. This change in simpleBufferPool seems worthwhile vs. adding a tier. We use simpleBufferPool for any size greater than 1MiB, so this effectively lets us discover a reasonably tight tier around any large message size that comes in frequently. It increases infrequent allocation sizes by no more than 0.4%. Adding a single tier to address my specific issue would increase 1MiB+epsilon allocations to 2MiB+4KiB, and adding more tiers seems like wasteful over-tuning. RELEASE NOTES: * mem: round up to nearest 4KiB for pool allocations larger than 1MiB
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #8705 +/- ##
==========================================
+ Coverage 83.29% 83.33% +0.03%
==========================================
Files 416 416
Lines 32267 32268 +1
==========================================
+ Hits 26876 26889 +13
+ Misses 4017 4010 -7
+ Partials 1374 1369 -5
🚀 New features to boost your workflow:
|
arjan-bal
reviewed
Nov 13, 2025
arjan-bal
approved these changes
Nov 14, 2025
Contributor
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. Adding a second reviewer.
Contributor
Author
|
Gentle ping on this review. Thanks. |
easwars
approved these changes
Nov 17, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Area: Transport
Includes HTTP/2 client/server and HTTP server handler transports and advanced transport features.
Type: Performance
Performance improvements (CPU, network, memory, etc)
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
By rounding up to the nearest page, we avoid repeatedly allocating similar sizes if requests happen to arrive in roughly increasing order.
The GCS client sends messages with 2MiB of data repeatedly when writing a large object. Therefore it has to repeatedly allocate just over 2MiB. This ultimately results in many, many allocations in the fallback buffer pool. In practice rounding up yields at least a 10x reduction in RAM when running 100 concurrent large writes. This is probably not unique to GCS: anyone who sends large messages may be affected.
This change in simpleBufferPool seems worthwhile vs. adding a tier. We use simpleBufferPool for any size greater than 1MiB, so this effectively lets us discover a reasonably tight tier around any large message size that comes in frequently. It increases infrequent allocation sizes by no more than 0.4%.
RELEASE NOTES: