Skip to content

Commit 62c5599

Browse files
committed
introduce new stats item EvictedBytes
It's incremented on bucket clean up and reports bytes evicted from memory. It should help to understand an amount of extra memory needed for fastcache to serve requests rate on constantly evicted keys. Related PR VictoriaMetrics/VictoriaMetrics#9293
1 parent b5e65a9 commit 62c5599

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

fastcache.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,9 @@ type bucket struct {
237237
// idx points to chunks for writing the next (k, v) pair.
238238
idx uint64
239239

240-
collisions uint64
241-
corruptions uint64
240+
collisions uint64
241+
corruptions uint64
242+
evictedBytes uint64
242243
}
243244

244245
func (b *bucket) Init(maxBytes uint64) {
@@ -376,6 +377,7 @@ func (b *bucket) Set(k, v []byte, h uint64) {
376377
b.idx = idxNew
377378
if needClean {
378379
b.cleanLocked()
380+
atomic.AddUint64(&b.evictedBytes, uint64(len(chunks)*chunkSize))
379381
}
380382
b.mu.Unlock()
381383
}

0 commit comments

Comments
 (0)