Skip to content

Commit 472f4e0

Browse files
authored
Reintroduce emit-plan for TPC-H benchmark (#3124)
just seems it got lost somewhere with all the recent changes?
1 parent d0f3ab8 commit 472f4e0

File tree

3 files changed

+26
-17
lines changed

3 files changed

+26
-17
lines changed

bench-vortex/src/bin/clickbench.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ struct DataFusionCtx {
8585
)>,
8686

8787
session: SessionContext,
88-
emit_execution_plan: bool,
88+
emit_plan: bool,
8989
}
9090

9191
struct DuckDBCtx {
@@ -108,12 +108,12 @@ enum EngineCtx {
108108
}
109109

110110
impl EngineCtx {
111-
fn new_with_datafusion(session_ctx: SessionContext, emit_execution_plan: bool) -> Self {
111+
fn new_with_datafusion(session_ctx: SessionContext, emit_plan: bool) -> Self {
112112
EngineCtx::DataFusion(DataFusionCtx {
113113
execution_plans: Vec::new(),
114114
metrics: Vec::new(),
115115
session: session_ctx,
116-
emit_execution_plan,
116+
emit_plan,
117117
})
118118
}
119119

@@ -438,37 +438,37 @@ fn execute_queries(
438438
) -> Vec<QueryMeasurement> {
439439
let mut query_measurements = Vec::default();
440440

441-
for (query_idx, query_string) in queries {
441+
for &(query_idx, ref query_string) in queries.iter() {
442442
match engine_ctx {
443443
EngineCtx::DataFusion(ctx) => {
444444
let (fastest_run, execution_plan) = benchmark_datafusion_query(
445-
*query_idx,
445+
query_idx,
446446
query_string,
447447
iterations,
448448
&ctx.session,
449449
tokio_runtime,
450450
);
451451

452452
ctx.execution_plans
453-
.push((*query_idx, execution_plan.clone()));
453+
.push((query_idx, execution_plan.clone()));
454454

455-
if ctx.emit_execution_plan {
455+
if ctx.emit_plan {
456456
df::write_execution_plan(
457-
*query_idx,
457+
query_idx,
458458
file_format,
459459
CLICKBENCH_DATASET,
460-
&execution_plan,
460+
execution_plan.as_ref(),
461461
);
462462
}
463463

464464
ctx.metrics.push((
465-
*query_idx,
465+
query_idx,
466466
file_format,
467467
VortexMetricsFinder::find_all(execution_plan.as_ref()),
468468
));
469469

470470
query_measurements.push(QueryMeasurement {
471-
query_idx: *query_idx,
471+
query_idx,
472472
target: Target::new(Engine::DataFusion, file_format),
473473
storage: STORAGE_NVME.to_owned(),
474474
fastest_run,
@@ -478,14 +478,14 @@ fn execute_queries(
478478

479479
EngineCtx::DuckDB(args) => {
480480
let fastest_run = benchmark_duckdb_query(
481-
*query_idx,
481+
query_idx,
482482
query_string,
483483
iterations,
484484
&DuckDBExecutor::new(args.duckdb_path.clone(), args.duckdb_file(file_format)),
485485
);
486486

487487
query_measurements.push(QueryMeasurement {
488-
query_idx: *query_idx,
488+
query_idx,
489489
target: Target::new(Engine::DuckDB, file_format),
490490
storage: STORAGE_NVME.to_owned(),
491491
fastest_run,

bench-vortex/src/bin/tpch.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
use std::path::PathBuf;
12
use std::process::ExitCode;
23
use std::time::{Duration, Instant};
34

45
use bench_vortex::ddb::{DuckDBExecutor, register_tables};
6+
use bench_vortex::df::write_execution_plan;
57
use bench_vortex::display::{DisplayFormat, RatioMode, print_measurements_json, render_table};
68
use bench_vortex::measurements::QueryMeasurement;
79
use bench_vortex::metrics::{MetricsSetExt, export_plan_spans};
@@ -43,7 +45,7 @@ struct Args {
4345
)]
4446
targets: Vec<Target>,
4547
#[arg(long)]
46-
duckdb_path: Option<std::path::PathBuf>,
48+
duckdb_path: Option<PathBuf>,
4749
#[arg(short, long, value_delimiter = ',')]
4850
queries: Option<Vec<usize>>,
4951
#[arg(short, long, value_delimiter = ',')]
@@ -180,6 +182,7 @@ fn main() -> ExitCode {
180182
url,
181183
args.all_metrics,
182184
args.export_spans,
185+
args.emit_plan,
183186
&args.duckdb_path,
184187
))
185188
}
@@ -298,7 +301,8 @@ async fn bench_main(
298301
url: Url,
299302
display_all_metrics: bool,
300303
export_spans: bool,
301-
duckdb_path: &Option<std::path::PathBuf>,
304+
emit_plan: bool,
305+
duckdb_path: &Option<PathBuf>,
302306
) -> ExitCode {
303307
let expected_row_counts = if scale_factor == 1 {
304308
EXPECTED_ROW_COUNTS_SF1
@@ -379,6 +383,11 @@ async fn bench_main(
379383
],
380384
);
381385
}
386+
387+
if emit_plan {
388+
write_execution_plan(query_idx, format, TPCH_DATASET, plan.as_ref());
389+
}
390+
382391
plans.push((query_idx, plan.clone()));
383392

384393
let storage = match bench_vortex::utils::url_scheme_to_storage(&url) {

bench-vortex/src/engines/df/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ pub fn write_execution_plan(
138138
query_idx: usize,
139139
format: crate::Format,
140140
dataset_name: &str,
141-
execution_plan: &Arc<dyn ExecutionPlan>,
141+
execution_plan: &dyn ExecutionPlan,
142142
) {
143143
fs::write(
144144
format!("{dataset_name}_{format}_q{query_idx:02}.plan"),
@@ -150,7 +150,7 @@ pub fn write_execution_plan(
150150
format!("{dataset_name}_{format}_q{query_idx:02}.short.plan"),
151151
format!(
152152
"{}",
153-
DisplayableExecutionPlan::with_full_metrics(execution_plan.as_ref())
153+
DisplayableExecutionPlan::with_full_metrics(execution_plan)
154154
.set_show_schema(true)
155155
.set_show_statistics(true)
156156
.indent(true)

0 commit comments

Comments
 (0)