Skip to content

Commit 662a3ba

Browse files
fix: inverted null_percent logic in in_list benchmark (#19204)
## Which issue does this PR close? N/A - benchmark fix discovered during performance analysis of #18832. ## Rationale for this change The `in_list` benchmark (introduced in #4068) had inverted null generation logic: `null_percent=0` was producing 100% nulls instead of 0% nulls. ## What changes are included in this PR? Fix the `random_bool(null_percent).then(...)` pattern to use `random_bool(1.0 - null_percent)` so that `null_percent` correctly represents the percentage of null values. ## Are these changes tested? Benchmark-only change. Verified by running the benchmark and observing expected performance characteristics. ## Are there any user-facing changes? No.
1 parent 0812d27 commit 662a3ba

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

datafusion/physical-expr/benches/in_list.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,12 @@ fn do_benches(
4949
null_percent: f64,
5050
) {
5151
let mut rng = StdRng::seed_from_u64(120320);
52+
let non_null_percent = 1.0 - null_percent;
53+
5254
for string_length in [5, 10, 20] {
5355
let values: StringArray = (0..array_length)
5456
.map(|_| {
55-
rng.random_bool(null_percent)
57+
rng.random_bool(non_null_percent)
5658
.then(|| random_string(&mut rng, string_length))
5759
})
5860
.collect();
@@ -72,7 +74,7 @@ fn do_benches(
7274
}
7375

7476
let values: Float32Array = (0..array_length)
75-
.map(|_| rng.random_bool(null_percent).then(|| rng.random()))
77+
.map(|_| rng.random_bool(non_null_percent).then(|| rng.random()))
7678
.collect();
7779

7880
let in_list: Vec<_> = (0..in_list_length)
@@ -87,7 +89,7 @@ fn do_benches(
8789
);
8890

8991
let values: Int32Array = (0..array_length)
90-
.map(|_| rng.random_bool(null_percent).then(|| rng.random()))
92+
.map(|_| rng.random_bool(non_null_percent).then(|| rng.random()))
9193
.collect();
9294

9395
let in_list: Vec<_> = (0..in_list_length)

0 commit comments

Comments
 (0)