Increase chunkSize from 100 to 1000 to reduce lock contention

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.
This commit is contained in:
Junegunn Choi
2026-02-20 23:59:21 +09:00
parent 09fe3a4180
commit 09ca45f7db

View File

@@ -39,7 +39,7 @@ const (
progressMinDuration = 200 * time.Millisecond progressMinDuration = 200 * time.Millisecond
// Capacity of each chunk // Capacity of each chunk
chunkSize int = 100 chunkSize int = 1000
// Pre-allocated memory slices to minimize GC // Pre-allocated memory slices to minimize GC
slab16Size int = 100 * 1024 // 200KB * 32 = 12.8MB slab16Size int = 100 * 1024 // 200KB * 32 = 12.8MB