Skip to content

Use labels Bytes() rather than String() for map key #5095

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

Merged
merged 1 commit into from
Jan 17, 2023

Conversation

yeya24
Copy link
Contributor

@yeya24 yeya24 commented Jan 14, 2023

Signed-off-by: Ben Ye [email protected]

What this PR does:

Use string(labels.Bytes()) instead of labels.String() for the deduplication map key. Since we don't have to print the map key, we just use the key to find the samples and as long as it remains the same sorting order, we can safely replace the method.

Benchmark

name    old time/op    new time/op    delta
Label-10    9.60µs ± 0%    1.60µs ± 0%   ~     (p=1.000 n=1+1)

name    old alloc/op   new alloc/op   delta
Label-10    7.79kB ± 0%    3.71kB ± 0%   ~     (p=1.000 n=1+1)

name    old allocs/op  new allocs/op  delta
Label-10       111 ± 0%         2 ± 0%   ~     (p=1.000 n=1+1)

Which issue(s) this PR fixes:
Fixes #

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

@yeya24 yeya24 force-pushed the optimize-sort-key branch from 64344c7 to fe399de Compare January 14, 2023 08:24
Copy link
Member

@alanprot alanprot left a comment

Choose a reason for hiding this comment

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

LGTM

@yeya24 yeya24 merged commit 402ccc9 into cortexproject:master Jan 17, 2023
alexqyle pushed a commit to alexqyle/cortex that referenced this pull request May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants