From 43103be011955d398a899fbea71e4116eb0d6412 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Mon, 5 Jul 2021 14:22:55 +0300 Subject: [PATCH] lib/{storage,mergeset}: increase cache timeout for data and index blocks from a minute to two minutes One minute cache timeout result in slower queries in some production workloads where the interval between query execution is in the range 1 minute - 2 minutes. --- lib/mergeset/part.go | 8 ++++---- lib/storage/part.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/mergeset/part.go b/lib/mergeset/part.go index 2fb5607e6..e8b78543e 100644 --- a/lib/mergeset/part.go +++ b/lib/mergeset/part.go @@ -205,9 +205,9 @@ func (idxbc *indexBlockCache) cleanByTimeout() { currentTime := fasttime.UnixTimestamp() idxbc.mu.Lock() for k, idxbe := range idxbc.m { - // Delete items accessed more than a minute ago. + // Delete items accessed more than two minutes ago. // This time should be enough for repeated queries. - if currentTime-atomic.LoadUint64(&idxbe.lastAccessTime) > 60 { + if currentTime-atomic.LoadUint64(&idxbe.lastAccessTime) > 2*60 { delete(idxbc.m, k) } } @@ -350,9 +350,9 @@ func (ibc *inmemoryBlockCache) cleanByTimeout() { currentTime := fasttime.UnixTimestamp() ibc.mu.Lock() for k, ibe := range ibc.m { - // Delete items accessed more than a minute ago. + // Delete items accessed more than two minutes ago. // This time should be enough for repeated queries. - if currentTime-atomic.LoadUint64(&ibe.lastAccessTime) > 60 { + if currentTime-atomic.LoadUint64(&ibe.lastAccessTime) > 2*60 { delete(ibc.m, k) } } diff --git a/lib/storage/part.go b/lib/storage/part.go index f5949f1ed..9638df758 100644 --- a/lib/storage/part.go +++ b/lib/storage/part.go @@ -204,9 +204,9 @@ func (ibc *indexBlockCache) cleanByTimeout() { currentTime := fasttime.UnixTimestamp() ibc.mu.Lock() for k, ibe := range ibc.m { - // Delete items accessed more than a minute ago. + // Delete items accessed more than two minutes ago. // This time should be enough for repeated queries. - if currentTime-atomic.LoadUint64(&ibe.lastAccessTime) > 60 { + if currentTime-atomic.LoadUint64(&ibe.lastAccessTime) > 2*60 { delete(ibc.m, k) } }