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.
The PR aims to optimize deduplication of profiles from uncompacted blocks.
Queriers stream profiles from replicas (ingesters) ordered by timestamp, and then by series labels, handling the streams in a k-way merge fashion (loser tree). Profiles with matching series labels and timestamps are deduplicated.
In large-scale deployments, this causes significant latencies due to the cost of series labels unmarshalling and comparison in queriers (stream deduplication is a single-thread operation).
The change exploits the fact that profiles are ordered by time, and a low number of profiles with matching timestamps is expected. Instead of streaming deduplication based on time and series order, we employ a map (set) that stores series fingerprints for the current timestamp. This allows us to send fingerprints instead of labels and eliminate expensive operations completely:
The change is fully backward compatible, but makes it impossible to change the deduplication order as per #2192 (here)