mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
app/vmselect/promql: add -search.disableCache
flag for disabling response caching
This may be useful for data back-filling, when the response caching could interfere badly with newly added data points with timestamps in the past.
This commit is contained in:
parent
17f0a53068
commit
53ea90865d
1 changed files with 9 additions and 2 deletions
|
@ -2,6 +2,7 @@ package promql
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sync"
|
"sync"
|
||||||
|
@ -15,6 +16,8 @@ import (
|
||||||
"github.com/VictoriaMetrics/metrics"
|
"github.com/VictoriaMetrics/metrics"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var disableCache = flag.Bool("search.disableCache", false, "Whether to disable response caching. This may be useful during data backfilling")
|
||||||
|
|
||||||
var rollupResultCacheV = &rollupResultCache{
|
var rollupResultCacheV = &rollupResultCache{
|
||||||
fastcache.New(1024 * 1024), // This is a cache for testing.
|
fastcache.New(1024 * 1024), // This is a cache for testing.
|
||||||
}
|
}
|
||||||
|
@ -47,6 +50,10 @@ func InitRollupResultCache(cachePath string) {
|
||||||
} else {
|
} else {
|
||||||
c = fastcache.New(getRollupResultCacheSize())
|
c = fastcache.New(getRollupResultCacheSize())
|
||||||
}
|
}
|
||||||
|
if *disableCache {
|
||||||
|
c.Reset()
|
||||||
|
}
|
||||||
|
|
||||||
stats := &fastcache.Stats{}
|
stats := &fastcache.Stats{}
|
||||||
var statsLock sync.Mutex
|
var statsLock sync.Mutex
|
||||||
var statsLastUpdate time.Time
|
var statsLastUpdate time.Time
|
||||||
|
@ -119,7 +126,7 @@ func ResetRollupResultCache() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rrc *rollupResultCache) Get(funcName string, ec *EvalConfig, me *metricExpr, window int64) (tss []*timeseries, newStart int64) {
|
func (rrc *rollupResultCache) Get(funcName string, ec *EvalConfig, me *metricExpr, window int64) (tss []*timeseries, newStart int64) {
|
||||||
if !ec.mayCache() {
|
if *disableCache || !ec.mayCache() {
|
||||||
return nil, ec.Start
|
return nil, ec.Start
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +197,7 @@ func (rrc *rollupResultCache) Get(funcName string, ec *EvalConfig, me *metricExp
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rrc *rollupResultCache) Put(funcName string, ec *EvalConfig, me *metricExpr, window int64, tss []*timeseries) {
|
func (rrc *rollupResultCache) Put(funcName string, ec *EvalConfig, me *metricExpr, window int64, tss []*timeseries) {
|
||||||
if len(tss) == 0 || !ec.mayCache() {
|
if *disableCache || len(tss) == 0 || !ec.mayCache() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue