Skip to content
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

perf: optimize deduplication #3351

Merged
merged 7 commits into from
Jun 11, 2024
Merged

Conversation

kolesnikovae
Copy link
Collaborator

@kolesnikovae kolesnikovae commented Jun 11, 2024

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).

image

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:

image

The change is fully backward compatible, but makes it impossible to change the deduplication order as per #2192 (here)

@kolesnikovae kolesnikovae marked this pull request as ready for review June 11, 2024 05:12
@kolesnikovae kolesnikovae requested a review from a team as a code owner June 11, 2024 05:12
@kolesnikovae kolesnikovae merged commit efc7f2a into main Jun 11, 2024
16 checks passed
@kolesnikovae kolesnikovae deleted the feat/optimized-deduplication branch June 11, 2024 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants