Skip to content
Myr

Increase chunkSize from 100 to 1000 to reduce lock contention

Before adoption: this commit came in with the history the project adopted, so no landing records it.

With chunkSize=100 and 10M items, 100K chunks cause ~300K mutex lock/unlock operations per search across 32 goroutines competing for a single sync.Mutex in ChunkCache. Increasing to 1000 reduces chunks to 10K, cutting contention overhead. Benchmarks on 10M items show 14-80% faster searches depending on query selectivity.

authored by Junegunn Choi · committed by Junegunn Choi · parent 09fe3a4 · Browse files · 1 file+1 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+1 added−1 removed

  • other:+1 added−1 removed

1 file+1 added−1 removed

modified:src/constants.go+1 added-1 removed
37 unmodified lines
38 maxPartitions = 3239 progressMinDuration = 200 * time.Millisecond4041 // Capacity of each chunk42 chunkSize int = 10042 chunkSize int = 10004344 // Pre-allocated memory slices to minimize GC45 slab16Size int = 100 * 1024 // 200KB * 32 = 12.8MB46 slab32Size int = 2048 // 8KB * 32 = 256KB
33 unmodified lines