-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add bloom filter folding to automatically size SBBF filters #9628
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
Merged
Merged
Changes from 28 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
619f14a
Add bloom filter folding to automatically size SBBF filters
adriangb 9f58be2
Revert default FPP change, add documentation with references
adriangb a262533
Fix rustdoc lint errors in bloom filter folding docs
adriangb 9670203
fmt
adriangb dc00ce0
write proof
friendlymatthew f3dd1b8
Update parquet/src/bloom_filter/mod.rs
adriangb cedad54
Update parquet/src/bloom_filter/mod.rs
adriangb ffbb59f
Update parquet/src/bloom_filter/mod.rs
adriangb 07c9902
address pr feedback
adriangb c07c7d7
tweak docs, rename variables to encapsulate domains
adriangb a95b638
add test for fixed size / ndv filters
adriangb c6dc8a2
simplify
adriangb d7589a8
simplify
adriangb a1090ed
tweak test
adriangb 70a1521
fix bloom filter NDV test to actually test underestimate path
adriangb 850143f
Update parquet/src/bloom_filter/mod.rs
adriangb d0656aa
optimize bloom filter folding performance and add benchmark
adriangb 7e33617
further optimize bloom filter folding: zero-alloc, SIMD-friendly codegen
adriangb 9a6d741
move cast
adriangb fbea1e1
lint
adriangb 8611ba8
address review: assert even block count in estimated_fpp_after_fold, …
adriangb a752620
use tree reduction to determine fold count, then fold in single pass
adriangb b2a0e3f
refactor: split fold_to_target_fpp into num_folds_for_target_fpp + fo…
adriangb 0f3500a
add insert-only benchmark to isolate fold overhead
adriangb a1713fa
use analytical FPP estimate to determine fold count, eliminating scra…
adriangb 50eff0d
lint
adriangb bb6c3a9
keep BloomFilterProperties::ndv as u64 to avoid breaking API change
adriangb eb88b69
fmt
adriangb e8e8b8b
add power of 2 assertion
adriangb 0c6b449
update docstring
adriangb 390fbed
add more docstrings
adriangb 07bf922
more docs
adriangb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| use criterion::{BenchmarkId, Criterion, Throughput, criterion_group, criterion_main}; | ||
| use parquet::bloom_filter::Sbbf; | ||
|
|
||
| /// Build a bloom filter sized for `initial_ndv` at `fpp`, insert `num_values` distinct values, | ||
| /// and return it ready for folding. | ||
| fn build_filter(initial_ndv: u64, fpp: f64, num_values: u64) -> Sbbf { | ||
| let mut sbbf = Sbbf::new_with_ndv_fpp(initial_ndv, fpp).unwrap(); | ||
| for i in 0..num_values { | ||
| sbbf.insert(&i); | ||
| } | ||
| sbbf | ||
| } | ||
|
|
||
| fn bench_fold_to_target_fpp(c: &mut Criterion) { | ||
| let mut group = c.benchmark_group("fold_to_target_fpp"); | ||
|
|
||
| // Realistic scenario: filter sized for 1M NDV, varying actual distinct values | ||
| let initial_ndv = 1_000_000u64; | ||
| let fpp = 0.05; | ||
|
|
||
| for num_values in [1_000u64, 10_000, 100_000] { | ||
| let filter = build_filter(initial_ndv, fpp, num_values); | ||
| let num_blocks = filter.num_blocks(); | ||
| group.throughput(Throughput::Elements(num_blocks as u64)); | ||
| group.bench_with_input(BenchmarkId::new("ndv", num_values), &filter, |b, filter| { | ||
| b.iter_batched( | ||
| || filter.clone(), | ||
| |mut f| { | ||
| f.fold_to_target_fpp(fpp); | ||
| f | ||
| }, | ||
| criterion::BatchSize::SmallInput, | ||
| ); | ||
| }); | ||
| } | ||
| group.finish(); | ||
| } | ||
|
|
||
| fn bench_insert_and_fold(c: &mut Criterion) { | ||
| let mut group = c.benchmark_group("insert_and_fold"); | ||
|
|
||
| let initial_ndv = 1_000_000u64; | ||
| let fpp = 0.05; | ||
|
|
||
| for num_values in [1_000u64, 10_000, 100_000] { | ||
| group.throughput(Throughput::Elements(num_values)); | ||
| group.bench_with_input( | ||
| BenchmarkId::new("values", num_values), | ||
| &num_values, | ||
| |b, &num_values| { | ||
| b.iter(|| { | ||
| let mut sbbf = Sbbf::new_with_ndv_fpp(initial_ndv, fpp).unwrap(); | ||
| for i in 0..num_values { | ||
| sbbf.insert(&i); | ||
| } | ||
| sbbf.fold_to_target_fpp(fpp); | ||
| sbbf | ||
| }); | ||
| }, | ||
| ); | ||
| } | ||
| group.finish(); | ||
| } | ||
|
|
||
| fn bench_insert_only(c: &mut Criterion) { | ||
| let mut group = c.benchmark_group("insert_only"); | ||
|
|
||
| let initial_ndv = 1_000_000u64; | ||
| let fpp = 0.05; | ||
|
|
||
| for num_values in [1_000u64, 10_000, 100_000] { | ||
| group.throughput(Throughput::Elements(num_values)); | ||
| group.bench_with_input( | ||
| BenchmarkId::new("values", num_values), | ||
| &num_values, | ||
| |b, &num_values| { | ||
| b.iter(|| { | ||
| let mut sbbf = Sbbf::new_with_ndv_fpp(initial_ndv, fpp).unwrap(); | ||
| for i in 0..num_values { | ||
| sbbf.insert(&i); | ||
| } | ||
| sbbf | ||
| }); | ||
| }, | ||
| ); | ||
| } | ||
| group.finish(); | ||
| } | ||
|
|
||
| criterion_group!( | ||
| benches, | ||
| bench_fold_to_target_fpp, | ||
| bench_insert_and_fold, | ||
| bench_insert_only | ||
| ); | ||
| criterion_main!(benches); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
array has only 7 distinct value. So "NDV smaller than actual distinct values" seems incorrect?