Skip to content

Commit afdabb2

Browse files
authored
[Benchmarks] Make partitions default to number of cores instead of 2 (#8292)
* Default partitions to num cores * update test
1 parent 952e7c3 commit afdabb2

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

benchmarks/src/sort.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,9 @@ impl RunOpt {
148148
println!("Executing '{title}' (sorting by: {expr:?})");
149149
rundata.start_new_case(title);
150150
for i in 0..self.common.iterations {
151-
let config =
152-
SessionConfig::new().with_target_partitions(self.common.partitions);
151+
let config = SessionConfig::new().with_target_partitions(
152+
self.common.partitions.unwrap_or(num_cpus::get()),
153+
);
153154
let ctx = SessionContext::new_with_config(config);
154155
let (rows, elapsed) =
155156
exec_sort(&ctx, &expr, &test_file, self.common.debug).await?;

benchmarks/src/tpch/run.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ impl RunOpt {
285285
}
286286

287287
fn partitions(&self) -> usize {
288-
self.common.partitions
288+
self.common.partitions.unwrap_or(num_cpus::get())
289289
}
290290
}
291291

@@ -325,7 +325,7 @@ mod tests {
325325
let path = get_tpch_data_path()?;
326326
let common = CommonOpt {
327327
iterations: 1,
328-
partitions: 2,
328+
partitions: Some(2),
329329
batch_size: 8192,
330330
debug: false,
331331
};
@@ -357,7 +357,7 @@ mod tests {
357357
let path = get_tpch_data_path()?;
358358
let common = CommonOpt {
359359
iterations: 1,
360-
partitions: 2,
360+
partitions: Some(2),
361361
batch_size: 8192,
362362
debug: false,
363363
};

benchmarks/src/util/options.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ pub struct CommonOpt {
2626
#[structopt(short = "i", long = "iterations", default_value = "3")]
2727
pub iterations: usize,
2828

29-
/// Number of partitions to process in parallel
30-
#[structopt(short = "n", long = "partitions", default_value = "2")]
31-
pub partitions: usize,
29+
/// Number of partitions to process in parallel. Defaults to number of available cores.
30+
#[structopt(short = "n", long = "partitions")]
31+
pub partitions: Option<usize>,
3232

3333
/// Batch size when reading CSV or Parquet files
3434
#[structopt(short = "s", long = "batch-size", default_value = "8192")]
@@ -48,7 +48,7 @@ impl CommonOpt {
4848
/// Modify the existing config appropriately
4949
pub fn update_config(&self, config: SessionConfig) -> SessionConfig {
5050
config
51-
.with_target_partitions(self.partitions)
51+
.with_target_partitions(self.partitions.unwrap_or(num_cpus::get()))
5252
.with_batch_size(self.batch_size)
5353
}
5454
}

0 commit comments

Comments
 (0)