cuckoofilter icon indicating copy to clipboard operation
cuckoofilter copied to clipboard

improve performance

Open paulwe opened this issue 1 year ago • 4 comments

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

paulwe avatar Jun 10 '23 16:06 paulwe

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 avatar Jun 12 '23 02:06 MeteorsLiu

@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.

paulwe avatar Jun 12 '23 14:06 paulwe

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!

panmari avatar Jun 22 '23 17:06 panmari

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

paulwe avatar Jun 23 '23 05:06 paulwe