mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/workingsetcache: tune cache miss threshold for resetting the previous cache from 5% to 1%
It has been appeared that some production workloads could suffer for some time
after every reset of the previous cache when it gets less than 5% of requests
after the needed item isn't found in the current cache. This could result
in reduced cache hit rates, which, in turn, could increase CPU, disk IO and RAM
usage needed for reading, unpacking and caching the missed data from disk.
This commit reduces the cache miss threshold for resetting the previous cache from 5% to 1%.
This should reduce the possible negative impact after each cache reset by at least 5x,
while reducing the total memory used by caches.
This is a follow-up for d906d8573e
This commit is contained in:
parent
5ff6e0fb02
commit
71335e6024
1 changed files with 2 additions and 2 deletions
|
@ -164,7 +164,7 @@ func (c *Cache) expirationWatcher(expireDuration time.Duration) {
|
|||
|
||||
func (c *Cache) prevCacheWatcher() {
|
||||
// Watch for the usage of the prev cache and drop it whenever it receives
|
||||
// less than 5% of requests comparing to the curr cache during the last 10 seconds.
|
||||
// less than 1% of requests comparing to the curr cache during the last 10 seconds.
|
||||
checkInterval := 10 * time.Second
|
||||
checkInterval += timeJitter(checkInterval / 10)
|
||||
t := time.NewTicker(checkInterval)
|
||||
|
@ -198,7 +198,7 @@ func (c *Cache) prevCacheWatcher() {
|
|||
}
|
||||
currGetCalls = csCurr.GetCalls
|
||||
prevGetCalls = csPrev.GetCalls
|
||||
if currRequests >= 20 && float64(prevRequests)/float64(currRequests) < 0.05 {
|
||||
if currRequests >= 100 && float64(prevRequests)/float64(currRequests) < 0.01 {
|
||||
// The majority of requests are served from the curr cache,
|
||||
// so the prev cache can be deleted in order to free up memory.
|
||||
if csPrev.EntriesCount > 0 {
|
||||
|
|
Loading…
Reference in a new issue