Skip to content

Commit 041b5f5

Browse files
committed
fix: unblock all-features benchmark checks
1 parent f3b1216 commit 041b5f5

5 files changed

Lines changed: 21 additions & 30 deletions

File tree

benchmarks/benches/sql.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,13 @@ static SQL_BENCHMARK_DIRECTORY: LazyLock<String> = LazyLock::new(|| {
4343
)
4444
});
4545

46-
#[cfg(all(feature = "snmalloc", feature = "mimalloc"))]
47-
compile_error!(
48-
"feature \"snmalloc\" and feature \"mimalloc\" cannot be enabled at the same time"
49-
);
50-
5146
#[cfg(feature = "snmalloc")]
5247
#[global_allocator]
5348
static ALLOC: snmalloc_rs::SnMalloc = snmalloc_rs::SnMalloc;
5449

55-
#[cfg(feature = "mimalloc")]
50+
// `cargo clippy --all-features` enables both allocator features, so prefer
51+
// `snmalloc` in that case and fall back to `mimalloc` otherwise.
52+
#[cfg(all(not(feature = "snmalloc"), feature = "mimalloc"))]
5653
#[global_allocator]
5754
static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;
5855

benchmarks/src/bin/benchmark_runner.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,13 @@
1717

1818
use datafusion_benchmarks::benchmark_runner::run_cli;
1919

20-
#[cfg(all(feature = "snmalloc", feature = "mimalloc"))]
21-
compile_error!(
22-
"feature \"snmalloc\" and feature \"mimalloc\" cannot be enabled at the same time"
23-
);
24-
2520
#[cfg(feature = "snmalloc")]
2621
#[global_allocator]
2722
static ALLOC: snmalloc_rs::SnMalloc = snmalloc_rs::SnMalloc;
2823

29-
#[cfg(feature = "mimalloc")]
24+
// `cargo clippy --all-features` enables both allocator features, so prefer
25+
// `snmalloc` in that case and fall back to `mimalloc` otherwise.
26+
#[cfg(all(not(feature = "snmalloc"), feature = "mimalloc"))]
3027
#[global_allocator]
3128
static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;
3229

benchmarks/src/bin/dfbench.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,13 @@ use datafusion::error::Result;
2020

2121
use clap::{Parser, Subcommand};
2222

23-
#[cfg(all(feature = "snmalloc", feature = "mimalloc"))]
24-
compile_error!(
25-
"feature \"snmalloc\" and feature \"mimalloc\" cannot be enabled at the same time"
26-
);
27-
2823
#[cfg(feature = "snmalloc")]
2924
#[global_allocator]
3025
static ALLOC: snmalloc_rs::SnMalloc = snmalloc_rs::SnMalloc;
3126

32-
#[cfg(feature = "mimalloc")]
27+
// `cargo clippy --all-features` enables both allocator features, so prefer
28+
// `snmalloc` in that case and fall back to `mimalloc` otherwise.
29+
#[cfg(all(not(feature = "snmalloc"), feature = "mimalloc"))]
3330
#[global_allocator]
3431
static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;
3532

benchmarks/src/bin/imdb.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,13 @@ use clap::{Parser, Subcommand};
2121
use datafusion::error::Result;
2222
use datafusion_benchmarks::imdb;
2323

24-
#[cfg(all(feature = "snmalloc", feature = "mimalloc"))]
25-
compile_error!(
26-
"feature \"snmalloc\" and feature \"mimalloc\" cannot be enabled at the same time"
27-
);
28-
2924
#[cfg(feature = "snmalloc")]
3025
#[global_allocator]
3126
static ALLOC: snmalloc_rs::SnMalloc = snmalloc_rs::SnMalloc;
3227

33-
#[cfg(feature = "mimalloc")]
28+
// `cargo clippy --all-features` enables both allocator features, so prefer
29+
// `snmalloc` in that case and fall back to `mimalloc` otherwise.
30+
#[cfg(all(not(feature = "snmalloc"), feature = "mimalloc"))]
3431
#[global_allocator]
3532
static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;
3633

datafusion/physical-plan/benches/aggregate_vectorized.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
use arrow::array::ArrayRef;
18+
use arrow::array::{ArrayRef, BooleanBufferBuilder};
1919
use arrow::datatypes::{Int32Type, StringViewType};
2020
use arrow::util::bench_util::{
2121
create_primitive_array, create_string_view_array_with_len,
@@ -289,13 +289,16 @@ fn vectorized_equal_to<GroupColumnBuilder: GroupColumn>(
289289
builder.vectorized_append(input, rows).unwrap();
290290

291291
b.iter(|| {
292-
// Cloning is a must as `vectorized_equal_to` will modify the input vec
293-
// and without cloning all benchmarks after the first one won't be meaningful
294-
let mut equal_to_results = equal_to_results.clone();
295-
builder.vectorized_equal_to(rows, input, rows, &mut equal_to_results);
292+
// Rebuilding is a must as `vectorized_equal_to` will modify the input
293+
// and without rebuilding all benchmarks after the first one won't be meaningful
294+
let mut equal_to_buffer = BooleanBufferBuilder::new(equal_to_results.len());
295+
for &value in &equal_to_results {
296+
equal_to_buffer.append(value);
297+
}
298+
builder.vectorized_equal_to(rows, input, rows, &mut equal_to_buffer);
296299

297300
// Make sure that the compiler does not optimize away the call
298-
black_box(equal_to_results);
301+
black_box(equal_to_buffer);
299302
});
300303
});
301304
}

0 commit comments

Comments
 (0)