Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions bloomfilter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down