From 8e03bc6b53a4261439c2392c552cdc0c8ba7c7c5 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Fri, 26 Jan 2024 21:13:38 +0100 Subject: [PATCH] app/vmselect/promql: do not spend CPU time on verifying whether the rollup cache needs to be reset for the given metric rows when it has been already instructed to reset --- app/vmselect/promql/rollup_result_cache.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/vmselect/promql/rollup_result_cache.go b/app/vmselect/promql/rollup_result_cache.go index 45d02be8d..996713ccf 100644 --- a/app/vmselect/promql/rollup_result_cache.go +++ b/app/vmselect/promql/rollup_result_cache.go @@ -43,6 +43,11 @@ func ResetRollupResultCacheIfNeeded(mrs []storage.MetricRow) { rollupResultResetMetricRowSample.Store(&storage.MetricRow{}) go checkRollupResultCacheReset() }) + if atomic.LoadUint32(&needRollupResultCacheReset) != 0 { + // The cache has been already instructed to reset. + return + } + minTimestamp := int64(fasttime.UnixTimestamp()*1000) - cacheTimestampOffset.Milliseconds() + checkRollupResultCacheResetInterval.Milliseconds() needCacheReset := false for i := range mrs {