lib/workingsetcache: reset the cache mode when the cache is reset

This should reduce memory usage if the working set is reduced after the cache reset.
This commit is contained in:
Aliaksandr Valialkin 2021-07-01 11:49:16 +03:00
parent ae485c2bfd
commit c25b839078
2 changed files with 4 additions and 0 deletions

View file

@ -6,6 +6,8 @@ sort: 15
## tip
* FEATURE: reduce memory usage when performing heavy queries over high number of time series.
* BUGFIX: remove `{ %space %}` typo in `/targets` output. The typo has been introduced in v1.62.0. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1408).

View file

@ -218,6 +218,8 @@ func (c *Cache) Reset() {
prev.Reset()
curr := c.curr.Load().(*fastcache.Cache)
curr.Reset()
// Reset the mode to `split` in the hope the working set size becomes smaller after the reset.
atomic.StoreUint64(&c.mode, split)
}
// UpdateStats updates fcs with cache stats.