diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2020-10-12 15:39:50 +0300 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2020-10-13 00:13:32 +0300 |
commit | b1e119dd15c4a79099bebd98531c840c2de52557 (patch) | |
tree | 1a5b11f37965820ef7b063be319d1900a36d8972 | |
parent | 96dc955a4c718f0cd8be2874252bec7e28c46e82 (diff) |
Update LRU cache values
-rw-r--r-- | internal/vfs/zip/archive.go | 4 | ||||
-rw-r--r-- | internal/vfs/zip/lru_cache.go | 14 | ||||
-rw-r--r-- | internal/vfs/zip/vfs.go | 4 |
3 files changed, 15 insertions, 7 deletions
diff --git a/internal/vfs/zip/archive.go b/internal/vfs/zip/archive.go index c91993c8..548ba651 100644 --- a/internal/vfs/zip/archive.go +++ b/internal/vfs/zip/archive.go @@ -26,9 +26,7 @@ const ( maxSymlinkSize = 256 // DefaultOpenTimeout to request an archive and read its contents the first time - DefaultOpenTimeout = 30 * time.Second - DataOffsetCacheInterval = 60 * time.Second - ReadLinkCacheInterval = 60 * time.Second + DefaultOpenTimeout = 30 * time.Second ) var ( diff --git a/internal/vfs/zip/lru_cache.go b/internal/vfs/zip/lru_cache.go index 62d252c4..fed5c360 100644 --- a/internal/vfs/zip/lru_cache.go +++ b/internal/vfs/zip/lru_cache.go @@ -8,6 +8,16 @@ import ( "gitlab.com/gitlab-org/gitlab-pages/metrics" ) +// lruCacheGetPerPromote is a value that makes the item to be promoted +// it is taken arbitrally as a sane value indicating that the item +// was frequently picked +// promotion moves the item to the front of the LRU list +const lruCacheGetsPerPromote = 64 + +// lruCacheItemsToPruneDiv is a value that indicates how much items +// needs to be pruned on OOM, this prunes 1/16 of items +const lruCacheItemsToPruneDiv = 16 + type lruCache struct { op string duration time.Duration @@ -17,8 +27,8 @@ type lruCache struct { func newLruCache(op string, maxEntries uint32, duration time.Duration) *lruCache { configuration := ccache.Configure() configuration.MaxSize(int64(maxEntries)) - configuration.ItemsToPrune(maxEntries / 16) - configuration.GetsPerPromote(64) // if item gets requested frequently promote it + configuration.ItemsToPrune(maxEntries / lruCacheItemsToPruneDiv) + configuration.GetsPerPromote(lruCacheGetsPerPromote) // if item gets requested frequently promote it configuration.OnDelete(func(*ccache.Item) { metrics.ZipCachedEntries.WithLabelValues(op).Dec() }) diff --git a/internal/vfs/zip/vfs.go b/internal/vfs/zip/vfs.go index 71899e80..67eb9465 100644 --- a/internal/vfs/zip/vfs.go +++ b/internal/vfs/zip/vfs.go @@ -21,12 +21,12 @@ const ( // we assume that each item costs around 100 bytes // this gives around 5MB of raw memory needed without acceleration structures defaultDataOffsetItems = 50000 - defaultDataOffsetExpirationInterval = time.Minute + defaultDataOffsetExpirationInterval = 15 * time.Minute // we assume that each item costs around 200 bytes // this gives around 2MB of raw memory needed without acceleration structures defaultReadlinkItems = 10000 - defaultReadlinkExpirationInterval = time.Minute + defaultReadlinkExpirationInterval = 15 * time.Minute ) var ( |