From 003e6084aef9c69948bd746ec9bc9a44b7d2bba2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 2 Nov 2025 03:17:56 +0000 Subject: [PATCH 1/2] Initial plan From c5eeb230eb547761a23831570edcf7d0e29a8abf Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 2 Nov 2025 03:24:21 +0000 Subject: [PATCH 2/2] docs: verify and document stack buffer escape analysis Co-authored-by: shaia <2351625+shaia@users.noreply.github.com> --- bloomfilter.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bloomfilter.go b/bloomfilter.go index 683e32f..33b4000 100644 --- a/bloomfilter.go +++ b/bloomfilter.go @@ -141,7 +141,9 @@ func (bf *CacheOptimizedBloomFilter) AddBatch(items [][]byte) { } // Stack-allocate positions buffer for typical filters (hashCount ≤ 8) - // Escape analysis confirms: positions does not escape when used locally + // Verified with go build -gcflags='-m': stackBuf and positions do not escape + // - positions slice is only read in loop, never stored or passed to goroutines + // - setBitCacheOptimizedWithOps reads positions without capturing it // Covers ~90% of use cases (FPR >= 0.01, where hashCount ≈ 7) var positions []uint64 if bf.hashCount <= 8 { @@ -191,7 +193,9 @@ func (bf *CacheOptimizedBloomFilter) AddBatchString(items []string) { } // Stack-allocate positions buffer for typical filters (hashCount ≤ 8) - // Escape analysis confirms: positions does not escape when used locally + // Verified with go build -gcflags='-m': stackBuf and positions do not escape + // - positions slice is only read in loop, never stored or passed to goroutines + // - setBitCacheOptimizedWithOps reads positions without capturing it // Covers ~90% of use cases (FPR >= 0.01, where hashCount ≈ 7) var positions []uint64 if bf.hashCount <= 8 { @@ -243,7 +247,9 @@ func (bf *CacheOptimizedBloomFilter) AddBatchUint64(items []uint64) { } // Stack-allocate positions buffer for typical filters (hashCount ≤ 8) - // Escape analysis confirms: positions does not escape when used locally + // Verified with go build -gcflags='-m': stackBuf and positions do not escape + // - positions slice is only read in loop, never stored or passed to goroutines + // - setBitCacheOptimizedWithOps reads positions without capturing it // Covers ~90% of use cases (FPR >= 0.01, where hashCount ≈ 7) var positions []uint64 if bf.hashCount <= 8 {