-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add function for checking indices of leaves which are set to zero #249
Conversation
Benchmark for 80b3da6Click to view benchmark
|
Benchmark for 576e171Click to view benchmark
|
Benchmark for 576e171Click to view benchmark
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this, added comments in-line for alternative approach, and noticed the subtree test is included here, is that intended?
self.cached_leaves_indices | ||
.iter() | ||
.take(next_idx) | ||
.enumerate() | ||
.filter(|&(_, &v)| v == 0u8) | ||
.map(|(idx, _)| idx) | ||
.collect() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if this is the best way to handle finding zero elements
perhaps we can employ a bloom filter and set values there?
quick napkin math suggests that we may use just ~3.5mb of memory vs 33mb
vec approach: 1048576 elements * 32 = 33mb at the cost of good performance
bloom filter: m = ceil((n * log(p)) / log(1 / pow(2, log(2))))
where n = 1048576, p = 1000k = 3.59mb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm, I need to think about it
If I think correctly, it will require rebuilding the filter every time we increase next_index? I'm not sure how much cost filter updating
oh, It's just misprint in function name, thank you for noticed |
Benchmark for 911e860Click to view benchmark
|
Benchmark for 911e860Click to view benchmark
|
b1c6fcd
to
0e0dfc2
Compare
Benchmark for 3a20f37Click to view benchmark
|
Benchmark for 3a20f37Click to view benchmark
|
Benchmark for 81048f0Click to view benchmark
|
Benchmark for 81048f0Click to view benchmark
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for this!
Part of #237
In general everything is ready, tests that helped to find problems from #248 are commented out for now.