Skip to content

Commit 250342f

Browse files
committed
right-size deathrow after sharding
1 parent cce7a01 commit 250342f

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

s3fifo.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ func newS3FIFO[K comparable, V any](cfg *config) *s3fifo[K, V] {
203203
size = 16384
204204
}
205205

206+
// Scale death row with capacity (was numShards × 8 with sharding).
207+
deathRowSize := max(minDeathRowSize, size/128)
208+
206209
c := &s3fifo[K, V]{
207210
mu: xsync.NewRBMutex(),
208211
entries: xsync.NewMap[K, *entry[K, V]](xsync.WithPresize(size)),
@@ -211,6 +214,7 @@ func newS3FIFO[K comparable, V any](cfg *config) *s3fifo[K, V] {
211214
ghostCap: size,
212215
ghostActive: newBloomFilter(size, ghostFPRate),
213216
ghostAging: newBloomFilter(size, ghostFPRate),
217+
deathRow: make([]*entry[K, V], deathRowSize),
214218
}
215219

216220
// Detect key type once to avoid type switch on every operation.

0 commit comments

Comments
 (0)