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

Adding experimental flag for Metrics Labels String Interning #6057

Merged
merged 3 commits into from
Jul 3, 2024

Conversation

alanprot
Copy link
Member

@alanprot alanprot commented Jul 3, 2024

What this PR does:
We implemented an experimental feature to dedup label strings in memory.

When adding a new series, we check if the string is already used by other series and if so, we return the previous reference for the same canonical string. Additionally, a reference count is maintained to determine when a string can be safely removed from memory.

The dedup is done on the PostCreation and PostDeletion hooks from TSDB.

As far as i can tell it seems safe to do so there as those hooks are called sync when creating the new series.

https://github.com/prometheus/prometheus/blob/main/tsdb/head.go#L2026

During initial testing, we observed a notable reduction in HEAP size on the ingesters, ranging from 25% to 30%. No changes on CPU was noticed.

Screenshot 2024-07-02 at 5 51 21 PM

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]

Signed-off-by: alanprot <alanprot@gmail.com>
Signed-off-by: alanprot <alanprot@gmail.com>
@alanprot alanprot marked this pull request as ready for review July 3, 2024 01:14
@alanprot alanprot requested review from yeya24 and friedrichg and removed request for yeya24 July 3, 2024 01:50
Copy link
Contributor

@yeya24 yeya24 left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link
Member

@CharlieTLe CharlieTLe left a comment

Choose a reason for hiding this comment

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

Copy link
Member

@friedrichg friedrichg left a comment

Choose a reason for hiding this comment

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

💥

Signed-off-by: alanprot <alanprot@gmail.com>
@alanprot alanprot enabled auto-merge (squash) July 3, 2024 16:05
@alanprot alanprot merged commit 18e5fb3 into cortexproject:master Jul 3, 2024
5 checks passed
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.

4 participants