Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use atomic.OrUint32 to set bits in SyncFilter (#11)
This is only enabled for Go 1.24 and up. It would work on 1.23, but then atomic.OrUint32 would not get intrinsified on amd64, causing a pretty big performance hit on that platform. Tested and benchmarked with go1.24-2bffb8b3fb. Checking whether the bit is already set, i.e., if atomic.LoadUint32(p)&bit == 0 { atomic.OrUint32(p, bit) } gives a 3× speedup for tiny Bloom filters (capacity 1e5) but slows things down at capacity 1e7. We optimize for the larger filters, at least for now. goos: linux goarch: amd64 pkg: github.com/greatroar/blobloom/benchmarks cpu: Intel(R) Core(TM) i7-3770K CPU @ 3.50GHz │ benchmarks/old │ benchmarks/check │ benchmarks/new │ │ sec/op │ sec/op vs base │ sec/op vs base │ Add1e5_1e2-8 14.81n ± 0% 13.99n ± 1% -5.60% (p=0.002 n=6) 43.58n ± 1% +194.13% (p=0.002 n=6) Add1e6_1e2-8 19.21n ± 1% 19.89n ± 1% +3.51% (p=0.002 n=6) 47.74n ± 0% +148.54% (p=0.002 n=6) Add1e7_1e2-8 103.70n ± 1% 89.63n ± 1% -13.56% (p=0.002 n=6) 75.22n ± 2% -27.47% (p=0.002 n=6) Add1e8_1e2-8 135.2n ± 0% 114.8n ± 1% -15.16% (p=0.002 n=6) 100.9n ± 1% -25.36% (p=0.002 n=6) Add1e5_1e3-8 21.14n ± 1% 19.50n ± 0% -7.76% (p=0.002 n=6) 66.45n ± 0% +214.28% (p=0.002 n=6) Add1e6_1e3-8 27.99n ± 0% 28.79n ± 1% +2.82% (p=0.002 n=6) 70.29n ± 0% +151.06% (p=0.002 n=6) Add1e7_1e3-8 149.0n ± 2% 122.3n ± 2% -17.89% (p=0.002 n=6) 106.1n ± 2% -28.83% (p=0.002 n=6) Add1e8_1e3-8 179.2n ± 0% 141.3n ± 0% -21.20% (p=0.002 n=6) 125.3n ± 1% -30.10% (p=0.002 n=6) geomean 53.09n 47.91n -9.76% 74.80n +40.90%
- Loading branch information