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

ref(metrics): Improve distribution value performance #2483

Merged
merged 5 commits into from
Sep 6, 2023

Conversation

jan-auer
Copy link
Member

@jan-auer jan-auer commented Sep 6, 2023

Represents distribution metrics as plain unsorted vectors instead of
deduplicated btree maps. This offers greatly improved performance
characteristics during insertion, but comes at the expense of
potentially more memory usage if there are a lot of duplicate values.

During benchmarks, this change reveals approximately 500x speedup for
metrics with 10k to 1M data points per bucket. In practice, large
buckets are much more prevalent than duplicate values.

The new implementation uses SmallVec. Since distribution values are
always stored within a BucketValue that also contains gauges. Since
GaugeValue is a larger struct, that leaves space to inline three float
values before allocating a vector for distributions. Usual production
traffic indicates that this covers the majority of distribution buckets,
so this is a worthwhile optimization.

@jan-auer jan-auer marked this pull request as ready for review September 6, 2023 12:47
@jan-auer jan-auer requested a review from a team September 6, 2023 12:47
Copy link
Contributor

@olksdr olksdr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm :shipit:

@jan-auer jan-auer merged commit 4841abe into master Sep 6, 2023
@jan-auer jan-auer deleted the ref/speed-up-distributions branch September 6, 2023 14:07
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.

2 participants