-
Notifications
You must be signed in to change notification settings - Fork 10
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
Track evictions in the PostingsForMatchers cache #824
Track evictions in the PostingsForMatchers cache #824
Conversation
Signed-off-by: Marco Pracucci <[email protected]>
Signed-off-by: Marco Pracucci <[email protected]>
tsdb/postings_for_matchers_cache.go
Outdated
if evictionReasons[evictionReasonTTL] > 0 { | ||
c.metrics.evictionsBecauseTTL.Add(float64(evictionReasons[evictionReasonTTL])) | ||
} | ||
if evictionReasons[evictionReasonMaxBytes] > 0 { | ||
c.metrics.evictionsBecauseMaxBytes.Add(float64(evictionReasons[evictionReasonMaxBytes])) | ||
} | ||
if evictionReasons[evictionReasonMaxItems] > 0 { | ||
c.metrics.evictionsBecauseMaxItems.Add(float64(evictionReasons[evictionReasonMaxItems])) | ||
} | ||
if evictionReasons[evictionReasonUnknown] > 0 { | ||
c.metrics.evictionsBecauseUnknown.Add(float64(evictionReasons[evictionReasonUnknown])) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are the if
s here necessary? If so, would be good to add a comment explaining why.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it was slightly after on high eviction rate (assuming most of the times cached promises are removed because of 1 out of 4 reasons), but benchmark doesn't show it far, so I've removed the if stataements.
goos: darwin
goarch: arm64
pkg: github.com/prometheus/prometheus/tsdb
cpu: Apple M3 Pro
│ before.txt │ after.txt │
│ sec/op │ sec/op vs base │
PostingsForMatchersCache/no_evictions-11 640.7n ± 3% 644.4n ± 9% ~ (p=0.260 n=6)
PostingsForMatchersCache/high_eviction_rate-11 10.75µ ± 0% 10.73µ ± 0% ~ (p=0.260 n=6)
PostingsForMatchersCache_ConcurrencyOnHighEvictionRate-11 338.6n ± 4% 332.5n ± 3% ~ (p=0.818 n=6)
geomean 1.326µ 1.320µ -0.45%
│ before.txt │ after.txt │
│ B/op │ B/op vs base │
PostingsForMatchersCache/no_evictions-11 974.0 ± 0% 974.0 ± 0% ~ (p=1.000 n=6) ¹
PostingsForMatchersCache/high_eviction_rate-11 26.32Ki ± 0% 26.32Ki ± 0% ~ (p=1.000 n=6) ¹
PostingsForMatchersCache_ConcurrencyOnHighEvictionRate-11 1.003Ki ± 1% 1.000Ki ± 1% ~ (p=0.571 n=6)
geomean 2.928Ki 2.926Ki -0.08%
¹ all samples are equal
│ before.txt │ after.txt │
│ allocs/op │ allocs/op vs base │
PostingsForMatchersCache/no_evictions-11 20.00 ± 0% 20.00 ± 0% ~ (p=1.000 n=6) ¹
PostingsForMatchersCache/high_eviction_rate-11 46.00 ± 0% 46.00 ± 0% ~ (p=1.000 n=6) ¹
PostingsForMatchersCache_ConcurrencyOnHighEvictionRate-11 21.00 ± 5% 20.00 ± 5% ~ (p=0.567 n=6)
geomean 26.83 26.40 -1.61%
¹ all samples are equal
Signed-off-by: Marco Pracucci <[email protected]>
In #822 I've introduced metrics for the
PostingsForMatchers
cache. In this PR I'm extending the metrics to count evictions by reason.Ref: https://github.com/grafana/pir-actions/issues/307
Benchmarks