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.
This commit is contained in:
Aliaksandr Valialkin 2021-07-15 16:12:01 +03:00
parent f4e81aef7e
commit 4ba3fd9e6d

View File

@ -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
}
}