lib/storage: consistency renaming: durationsPerDateTagFilterCache -> loopsPerDateTagFilterCache

This commit is contained in:
Aliaksandr Valialkin 2021-02-23 15:47:19 +02:00
parent b1409a7413
commit 06676c8feb

View file

@ -104,9 +104,9 @@ type indexDB struct {
// matching low number of metrics. // matching low number of metrics.
uselessTagFiltersCache *workingsetcache.Cache uselessTagFiltersCache *workingsetcache.Cache
// Cache for (date, tagFilter) -> filterDuration, which is used for reducing // Cache for (date, tagFilter) -> loopsCount, which is used for reducing
// the amount of work when matching a set of filters. // the amount of work when matching a set of filters.
durationsPerDateTagFilterCache *workingsetcache.Cache loopsPerDateTagFilterCache *workingsetcache.Cache
indexSearchPool sync.Pool indexSearchPool sync.Pool
@ -150,12 +150,12 @@ func openIndexDB(path string, metricIDCache, metricNameCache, tsidCache *working
tb: tb, tb: tb,
name: name, name: name,
tagCache: workingsetcache.New(mem/32, time.Hour), tagCache: workingsetcache.New(mem/32, time.Hour),
metricIDCache: metricIDCache, metricIDCache: metricIDCache,
metricNameCache: metricNameCache, metricNameCache: metricNameCache,
tsidCache: tsidCache, tsidCache: tsidCache,
uselessTagFiltersCache: workingsetcache.New(mem/128, time.Hour), uselessTagFiltersCache: workingsetcache.New(mem/128, 3*time.Hour),
durationsPerDateTagFilterCache: workingsetcache.New(mem/128, time.Hour), loopsPerDateTagFilterCache: workingsetcache.New(mem/128, 3*time.Hour),
minTimestampForCompositeIndex: minTimestampForCompositeIndex, minTimestampForCompositeIndex: minTimestampForCompositeIndex,
} }
@ -320,14 +320,14 @@ func (db *indexDB) decRef() {
// Free space occupied by caches owned by db. // Free space occupied by caches owned by db.
db.tagCache.Stop() db.tagCache.Stop()
db.uselessTagFiltersCache.Stop() db.uselessTagFiltersCache.Stop()
db.durationsPerDateTagFilterCache.Stop() db.loopsPerDateTagFilterCache.Stop()
db.tagCache = nil db.tagCache = nil
db.metricIDCache = nil db.metricIDCache = nil
db.metricNameCache = nil db.metricNameCache = nil
db.tsidCache = nil db.tsidCache = nil
db.uselessTagFiltersCache = nil db.uselessTagFiltersCache = nil
db.durationsPerDateTagFilterCache = nil db.loopsPerDateTagFilterCache = nil
if atomic.LoadUint64(&db.mustDrop) == 0 { if atomic.LoadUint64(&db.mustDrop) == 0 {
return return
@ -3130,7 +3130,7 @@ func (is *indexSearch) getLoopsCountAndTimestampForDateFilter(date uint64, tf *t
is.kb.B = appendDateTagFilterCacheKey(is.kb.B[:0], date, tf, is.accountID, is.projectID) is.kb.B = appendDateTagFilterCacheKey(is.kb.B[:0], date, tf, is.accountID, is.projectID)
kb := kbPool.Get() kb := kbPool.Get()
defer kbPool.Put(kb) defer kbPool.Put(kb)
kb.B = is.db.durationsPerDateTagFilterCache.Get(kb.B[:0], is.kb.B) kb.B = is.db.loopsPerDateTagFilterCache.Get(kb.B[:0], is.kb.B)
if len(kb.B) != 16 { if len(kb.B) != 16 {
return 0, 0 return 0, 0
} }
@ -3150,7 +3150,7 @@ func (is *indexSearch) storeLoopsCountForDateFilter(date uint64, tf *tagFilter,
kb := kbPool.Get() kb := kbPool.Get()
kb.B = encoding.MarshalUint64(kb.B[:0], loopsCount) kb.B = encoding.MarshalUint64(kb.B[:0], loopsCount)
kb.B = encoding.MarshalUint64(kb.B, currentTimestamp) kb.B = encoding.MarshalUint64(kb.B, currentTimestamp)
is.db.durationsPerDateTagFilterCache.Set(is.kb.B, kb.B) is.db.loopsPerDateTagFilterCache.Set(is.kb.B, kb.B)
kbPool.Put(kb) kbPool.Put(kb)
} }