From 09ca45f7db498ed8cef0bb1d3afe66921b88861b Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Fri, 20 Feb 2026 23:59:21 +0900 Subject: [PATCH] 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. --- src/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constants.go b/src/constants.go index 6f56fd58..5f5c8ca1 100644 --- a/src/constants.go +++ b/src/constants.go @@ -39,7 +39,7 @@ const ( progressMinDuration = 200 * time.Millisecond // Capacity of each chunk - chunkSize int = 100 + chunkSize int = 1000 // Pre-allocated memory slices to minimize GC slab16Size int = 100 * 1024 // 200KB * 32 = 12.8MB