From f8495a7f3fabb1cb7277e8b076fc366a52fd9ca8 Mon Sep 17 00:00:00 2001 From: Simon Vandel Sillesen Date: Wed, 31 Jan 2024 16:43:24 +0000 Subject: [PATCH] Split physical_plan_tpch into separate benchmarks (#9043) * Split physical_plan_tpch into separate benchmarks * comment on q15 * all tpch in one --- datafusion/core/benches/sql_planner.rs | 72 ++++++++++---------------- 1 file changed, 27 insertions(+), 45 deletions(-) diff --git a/datafusion/core/benches/sql_planner.rs b/datafusion/core/benches/sql_planner.rs index 1754129a768f..4615d0a0f55c 100644 --- a/datafusion/core/benches/sql_planner.rs +++ b/datafusion/core/benches/sql_planner.rs @@ -224,52 +224,34 @@ fn criterion_benchmark(c: &mut Criterion) { }) }); - let q1_sql = std::fs::read_to_string("../../benchmarks/queries/q1.sql").unwrap(); - let q2_sql = std::fs::read_to_string("../../benchmarks/queries/q2.sql").unwrap(); - let q3_sql = std::fs::read_to_string("../../benchmarks/queries/q3.sql").unwrap(); - let q4_sql = std::fs::read_to_string("../../benchmarks/queries/q4.sql").unwrap(); - let q5_sql = std::fs::read_to_string("../../benchmarks/queries/q5.sql").unwrap(); - let q6_sql = std::fs::read_to_string("../../benchmarks/queries/q6.sql").unwrap(); - let q7_sql = std::fs::read_to_string("../../benchmarks/queries/q7.sql").unwrap(); - let q8_sql = std::fs::read_to_string("../../benchmarks/queries/q8.sql").unwrap(); - let q9_sql = std::fs::read_to_string("../../benchmarks/queries/q9.sql").unwrap(); - let q10_sql = std::fs::read_to_string("../../benchmarks/queries/q10.sql").unwrap(); - let q11_sql = std::fs::read_to_string("../../benchmarks/queries/q11.sql").unwrap(); - let q12_sql = std::fs::read_to_string("../../benchmarks/queries/q12.sql").unwrap(); - let q13_sql = std::fs::read_to_string("../../benchmarks/queries/q13.sql").unwrap(); - let q14_sql = std::fs::read_to_string("../../benchmarks/queries/q14.sql").unwrap(); - // let q15_sql = std::fs::read_to_string("../../benchmarks/queries/q15.sql").unwrap(); - let q16_sql = std::fs::read_to_string("../../benchmarks/queries/q16.sql").unwrap(); - let q17_sql = std::fs::read_to_string("../../benchmarks/queries/q17.sql").unwrap(); - let q18_sql = std::fs::read_to_string("../../benchmarks/queries/q18.sql").unwrap(); - let q19_sql = std::fs::read_to_string("../../benchmarks/queries/q19.sql").unwrap(); - let q20_sql = std::fs::read_to_string("../../benchmarks/queries/q20.sql").unwrap(); - let q21_sql = std::fs::read_to_string("../../benchmarks/queries/q21.sql").unwrap(); - let q22_sql = std::fs::read_to_string("../../benchmarks/queries/q22.sql").unwrap(); + let tpch_queries = [ + "q1", "q2", "q3", "q4", "q5", "q6", "q7", "q8", "q9", "q10", "q11", "q12", "q13", + "q14", // "q15", q15 has multiple SQL statements which is not supported + "q16", "q17", "q18", "q19", "q20", "q21", "q22", + ]; - c.bench_function("physical_plan_tpch", |b| { - b.iter(|| physical_plan(&ctx, &q1_sql)); - b.iter(|| physical_plan(&ctx, &q2_sql)); - b.iter(|| physical_plan(&ctx, &q3_sql)); - b.iter(|| physical_plan(&ctx, &q4_sql)); - b.iter(|| physical_plan(&ctx, &q5_sql)); - b.iter(|| physical_plan(&ctx, &q6_sql)); - b.iter(|| physical_plan(&ctx, &q7_sql)); - b.iter(|| physical_plan(&ctx, &q8_sql)); - b.iter(|| physical_plan(&ctx, &q9_sql)); - b.iter(|| physical_plan(&ctx, &q10_sql)); - b.iter(|| physical_plan(&ctx, &q11_sql)); - b.iter(|| physical_plan(&ctx, &q12_sql)); - b.iter(|| physical_plan(&ctx, &q13_sql)); - b.iter(|| physical_plan(&ctx, &q14_sql)); - // b.iter(|| physical_plan(&ctx, &q15_sql)); - b.iter(|| physical_plan(&ctx, &q16_sql)); - b.iter(|| physical_plan(&ctx, &q17_sql)); - b.iter(|| physical_plan(&ctx, &q18_sql)); - b.iter(|| physical_plan(&ctx, &q19_sql)); - b.iter(|| physical_plan(&ctx, &q20_sql)); - b.iter(|| physical_plan(&ctx, &q21_sql)); - b.iter(|| physical_plan(&ctx, &q22_sql)); + for q in tpch_queries { + let sql = std::fs::read_to_string(format!("../../benchmarks/queries/{}.sql", q)) + .unwrap(); + c.bench_function(&format!("physical_plan_tpch_{}", q), |b| { + b.iter(|| logical_plan(&ctx, &sql)) + }); + } + + let all_tpch_sql_queries = tpch_queries + .iter() + .map(|q| { + std::fs::read_to_string(format!("../../benchmarks/queries/{}.sql", q)) + .unwrap() + }) + .collect::>(); + + c.bench_function("physical_plan_tpch_all", |b| { + b.iter(|| { + for sql in &all_tpch_sql_queries { + logical_plan(&ctx, sql) + } + }) }); }