Flatten distributeTimeseriesToReplicas data structures in receive/handler.go#309
Open
gavins-db wants to merge 3 commits intodatabricks:db_mainfrom
Open
Flatten distributeTimeseriesToReplicas data structures in receive/handler.go#309gavins-db wants to merge 3 commits intodatabricks:db_mainfrom
gavins-db wants to merge 3 commits intodatabricks:db_mainfrom
Conversation
- Introduce distributionKey struct to replace nested
map[endpointReplica]map[string]trackedSeries with flat
map[distributionKey]*trackedSeries
- Use replicaStart/replicaEnd range instead of []uint64 replicas slice
- Remove remoteWriteParams; pass replica and timeseries directly
- Update gatherWriteStats, sendWrites, sendLocalWrite, sendRemoteWrite
signatures to use the flattened map and pointer trackedSeries
- Update TestDistributeSeries for new signatures
Port descriptive comments for replica, distributionKey, and distributeTimeseriesToReplicas from the vtproto optimization branch. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
In some previous profiling I learned that
distributeTimeseriesToReplicaswhich returns amap[endpointReplica]map[string]trackedSeries, map[endpointReplica]map[string]trackedSeriesis allocating more objects than necessary due to that pattern, similarly, allocating areplicas []uint64,slice rather than just iterating between two numbers is also unnecessarily wasted memory.These are micro optimizations and are still largely overshadowed by other concerns but these changes are foundational to #306 (my vt migration) and really should just be pulled forward here. Furthermore, at least in my opinion, this makes what's happening under the hood significantly more easy to read and reason about.
Changes
Verification