From 4ba3fd9e6d97944b12f8f9e28e294aff2cbd95c6 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Thu, 15 Jul 2021 16:12:01 +0300 Subject: [PATCH] lib/workingsetcache: switch from split cache to full cache after the cache size exceeds 95% of split capacity Previously the switch occurred when the cache size becomes 100% of its capacity. The cache size could never reach 100% capacity. This could prevent from switching from the split cache to full cache, thus reducing the cache effectiveness. --- lib/workingsetcache/cache.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/workingsetcache/cache.go b/lib/workingsetcache/cache.go index 31f82e270f..7a96b1f5f7 100644 --- a/lib/workingsetcache/cache.go +++ b/lib/workingsetcache/cache.go @@ -153,7 +153,7 @@ func (c *Cache) cacheSizeWatcher() { var cs fastcache.Stats curr := c.curr.Load().(*fastcache.Cache) curr.UpdateStats(&cs) - if cs.BytesSize >= uint64(c.maxBytes)/2 { + if cs.BytesSize >= uint64(0.95*float64(c.maxBytes)/2) { break } }