From d128a5bf9916b612c22ae3d6b3f71b67c3ee2f45 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Wed, 23 Feb 2022 15:59:21 +0200 Subject: [PATCH] lib/workingsetcache: do not rotate cache if it is in `whole` state This should reduce the maximum memory usage for the cache in `whole` state --- lib/workingsetcache/cache.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/workingsetcache/cache.go b/lib/workingsetcache/cache.go index aab534b4d6..a5c583401b 100644 --- a/lib/workingsetcache/cache.go +++ b/lib/workingsetcache/cache.go @@ -172,6 +172,9 @@ func (c *Cache) cacheSizeWatcher() { return case <-t.C: } + if c.loadMode() != split { + continue + } var cs fastcache.Stats curr := c.curr.Load().(*fastcache.Cache) curr.UpdateStats(&cs) @@ -188,10 +191,10 @@ func (c *Cache) cacheSizeWatcher() { // Do this in the following steps: // 1) switch to mode=switching // 2) move curr cache to prev - // 3) create curr with the double size - // 4) wait until curr size exceeds maxBytesSize, i.e. it is populated with new data + // 3) create curr cache with doubled size + // 4) wait until curr cache size exceeds maxBytesSize, i.e. it is populated with new data // 5) switch to mode=whole - // 6) drop prev + // 6) drop prev cache c.mu.Lock() c.setMode(switching)