storepool: reduce getStoreListFromIDs allocations#171656
Open
shreyasganesh0 wants to merge 1 commit into
Open
Conversation
getStoreListFromIDs builds a StoreList and a ThrottledStoreReasons slice
on every replication and rebalancing decision, growing both result slices
via append from a nil start. On clusters with many stores this repeated
reallocate-and-copy was observed to allocate ~1GB over a 5s allocation
profile, adding GC pressure that can hurt foreground latency.
Both slices hold at most one entry per input store ID, so pre-allocate
them to len(storeIDs) capacity. The new BenchmarkGetStoreListFromIDs
(50 stores) shows the improvement:
name old new
GetStoreListFromIDs 81732 B/op 33711 B/op
8 allocs/op 3 allocs/op
Epic: none
Fixes: cockroachdb#151952
Release note: None
|
Thank you for contributing to CockroachDB. Please ensure you have followed the guidelines for creating a PR. My owl senses detect your PR is good for review. Please keep an eye out for any test failures in CI. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
getStoreListFromIDsbuilds aStoreListand aThrottledStoreReasonsslice on every replication and rebalancing decision, growing both result slices viaappendfrom a nil start. On clusters with many stores this repeated reallocate-and-copy was observed in #151952 to allocate ~1GB over a 5s allocation profile, adding GC pressure that can hurt foreground latency.Both slices hold at most one entry per input store ID, so this pre-allocates them to
len(storeIDs)capacity. A newBenchmarkGetStoreListFromIDs(50 stores) shows the improvement (same machine):Epic: none
Fixes: #151952