cuckoofilter
cuckoofilter copied to clipboard
improve performance
add the improvement to getAltIndex
by @MeteorsLiu from their abandoned pr.
simplify getNextPow2
use a per filter rng for randi
to avoid contention
preallocate temporary read/write buffer in encode/decode
pack buckets into uint64
before
goos: darwin
goarch: arm64
pkg: github.com/panmari/cuckoofilter
BenchmarkFilter_Reset
BenchmarkFilter_Reset-10 133612 8374 ns/op 0 B/op 0 allocs/op
BenchmarkFilter_Insert
BenchmarkFilter_Insert-10 54015536 22.35 ns/op 0 B/op 0 allocs/op
BenchmarkFilter_Lookup
BenchmarkFilter_Lookup-10 68751163 17.63 ns/op 0 B/op 0 allocs/op
PASS
after
goos: darwin
goarch: arm64
pkg: github.com/panmari/cuckoofilter
BenchmarkFilter_Reset
BenchmarkFilter_Reset-10 885447 1340 ns/op 0 B/op 0 allocs/op
BenchmarkFilter_Insert
BenchmarkFilter_Insert-10 140478770 8.548 ns/op 0 B/op 0 allocs/op
BenchmarkFilter_Lookup
BenchmarkFilter_Lookup-10 120644037 9.868 ns/op 0 B/op 0 allocs/op
I'm sorry that i forgot the pr. Because i infected the COVID-19 in that time, when i recovered from it, i forgot it...
@MeteorsLiu i'm sorry to hear that. i hope you're feeling better now! i added you as a coauthor to the diff i based on your work.
Thanks for putting together! With everything in one big pull requests, it's hard to evaluate how much each change individually contributes.
Could you please send individual PRs for all the changes you're making? That would immensely help with reviewing!
bfbb4b4
improves insert and lookup from 22 and 17 to 17 and 12 ns
88c5449
reduces allocations during import/export from one per fingerprint to one
c94c7db
reduces reset from 8370 to 1340 and insert and lookup from 17 and 12 to 8.5 and 9.9 ns