Skip to content

Apache DataFusion SQL Query Engine

Remove parquet_filter and parquet `sort` benchmarks (#16730)

Andrew Lambeb4f852b06a7
diff --git a/benchmarks/bench.sh b/benchmarks/bench.sh
index 1a687ac024..4890012fe5 100755
--- a/benchmarks/bench.sh
+++ b/benchmarks/bench.sh
@@ -114,8 +114,6 @@ imdb: Join Order Benchmark (JOB) using the IMDB dataset conver
# Micro-Benchmarks (specific operators and features)
cancellation: How long cancelling a query takes
-parquet: Benchmark of parquet reader's filtering speed
-sort: Benchmark of sorting speed
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Supported Configuration (Environment Variables)
@@ -303,8 +301,6 @@ main() {
run_tpch "10" "csv"
run_tpch_mem "10"
run_cancellation
- run_parquet
- run_sort
run_clickbench_1
run_clickbench_partitioned
run_clickbench_extended
@@ -338,12 +334,6 @@ main() {
cancellation)
run_cancellation
;;
- parquet)
- run_parquet
- ;;
- sort)
- run_sort
- ;;
clickbench_1)
run_clickbench_1
;;
@@ -528,22 +518,6 @@ run_cancellation() {
debug_run $CARGO_COMMAND --bin dfbench -- cancellation --iterations 5 --path "${DATA_DIR}/cancellation" -o "${RESULTS_FILE}"
}
-# Runs the parquet filter benchmark
-run_parquet() {
- RESULTS_FILE="${RESULTS_DIR}/parquet.json"
- echo "RESULTS_FILE: ${RESULTS_FILE}"
- echo "Running parquet filter benchmark..."
- debug_run $CARGO_COMMAND --bin parquet -- filter --path "${DATA_DIR}" --scale-factor 1.0 --iterations 5 -o "${RESULTS_FILE}"
-}
-
-# Runs the sort benchmark
-run_sort() {
- RESULTS_FILE="${RESULTS_DIR}/sort.json"
- echo "RESULTS_FILE: ${RESULTS_FILE}"
- echo "Running sort benchmark..."
- debug_run $CARGO_COMMAND --bin parquet -- sort --path "${DATA_DIR}" --scale-factor 1.0 --iterations 5 -o "${RESULTS_FILE}"
-}
-
# Downloads the single file hits.parquet ClickBench datasets from
# https://github.com/ClickHouse/ClickBench/tree/main#data-loading
diff --git a/benchmarks/src/bin/dfbench.rs b/benchmarks/src/bin/dfbench.rs
index 41b64063c0..e92fd115c7 100644
--- a/benchmarks/src/bin/dfbench.rs
+++ b/benchmarks/src/bin/dfbench.rs
@@ -33,9 +33,7 @@ static ALLOC: snmalloc_rs::SnMalloc = snmalloc_rs::SnMalloc;
#[global_allocator]
static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;
-use datafusion_benchmarks::{
- cancellation, clickbench, h2o, imdb, parquet_filter, sort, sort_tpch, tpch,
-};
+use datafusion_benchmarks::{cancellation, clickbench, h2o, imdb, sort_tpch, tpch};
#[derive(Debug, StructOpt)]
#[structopt(about = "benchmark command")]
@@ -44,8 +42,6 @@ enum Options {
Clickbench(clickbench::RunOpt),
H2o(h2o::RunOpt),
Imdb(imdb::RunOpt),
- ParquetFilter(parquet_filter::RunOpt),
- Sort(sort::RunOpt),
SortTpch(sort_tpch::RunOpt),
Tpch(tpch::RunOpt),
TpchConvert(tpch::ConvertOpt),
@@ -61,8 +57,6 @@ pub async fn main() -> Result<()> {
Options::Clickbench(opt) => opt.run().await,
Options::H2o(opt) => opt.run().await,
Options::Imdb(opt) => Box::pin(opt.run()).await,
- Options::ParquetFilter(opt) => opt.run().await,
- Options::Sort(opt) => opt.run().await,
Options::SortTpch(opt) => opt.run().await,
Options::Tpch(opt) => Box::pin(opt.run()).await,
Options::TpchConvert(opt) => opt.run().await,
diff --git a/benchmarks/src/bin/parquet.rs b/benchmarks/src/bin/parquet.rs
deleted file mode 100644
index 6351a71a7b..0000000000
--- a/benchmarks/src/bin/parquet.rs
+++ /dev/null
@@ -1,49 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-use datafusion::common::Result;
-
-use datafusion_benchmarks::{parquet_filter, sort};
-use structopt::StructOpt;
-
-#[cfg(feature = "snmalloc")]
-#[global_allocator]
-static ALLOC: snmalloc_rs::SnMalloc = snmalloc_rs::SnMalloc;
-
-#[derive(Debug, Clone, StructOpt)]
-#[structopt(name = "Benchmarks", about = "Apache DataFusion Rust Benchmarks.")]
-enum ParquetBenchCmd {
- /// Benchmark sorting parquet files
- Sort(sort::RunOpt),
- /// Benchmark parquet filter pushdown
- Filter(parquet_filter::RunOpt),
-}
-
-#[tokio::main]
-async fn main() -> Result<()> {
- let cmd = ParquetBenchCmd::from_args();
- match cmd {
- ParquetBenchCmd::Filter(opt) => {
- println!("running filter benchmarks");
- opt.run().await
- }
- ParquetBenchCmd::Sort(opt) => {
- println!("running sort benchmarks");
- opt.run().await
- }
- }
-}
diff --git a/benchmarks/src/lib.rs b/benchmarks/src/lib.rs
index a402fc1b8c..e7657c4078 100644
--- a/benchmarks/src/lib.rs
+++ b/benchmarks/src/lib.rs
@@ -20,8 +20,6 @@ pub mod cancellation;
pub mod clickbench;
pub mod h2o;
pub mod imdb;
-pub mod parquet_filter;
-pub mod sort;
pub mod sort_tpch;
pub mod tpch;
pub mod util;
diff --git a/benchmarks/src/parquet_filter.rs b/benchmarks/src/parquet_filter.rs
deleted file mode 100644
index 34103af0ff..0000000000
--- a/benchmarks/src/parquet_filter.rs
+++ /dev/null
@@ -1,194 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-use std::path::PathBuf;
-
-use crate::util::{AccessLogOpt, BenchmarkRun, CommonOpt};
-
-use arrow::util::pretty;
-use datafusion::common::Result;
-use datafusion::logical_expr::utils::disjunction;
-use datafusion::logical_expr::{lit, or, Expr};
-use datafusion::physical_plan::collect;
-use datafusion::prelude::{col, SessionContext};
-use datafusion::test_util::parquet::{ParquetScanOptions, TestParquetFile};
-use datafusion_common::instant::Instant;
-
-use structopt::StructOpt;
-
-/// Test performance of parquet filter pushdown
-///
-/// The queries are executed on a synthetic dataset generated during
-/// the benchmark execution and designed to simulate web server access
-/// logs.
-///
-/// Example
-///
-/// dfbench parquet-filter --path ./data --scale-factor 1.0
-///
-/// generates the synthetic dataset at `./data/logs.parquet`. The size
-/// of the dataset can be controlled through the `size_factor`
-/// (with the default value of `1.0` generating a ~1GB parquet file).
-///
-/// For each filter we will run the query using different
-/// `ParquetScanOption` settings.
-///
-/// Example output:
-///
-/// Running benchmarks with the following options: Opt { debug: false, iterations: 3, partitions: 2, path: "./data", batch_size: 8192, scale_factor: 1.0 }
-/// Generated test dataset with 10699521 rows
-/// Executing with filter 'request_method = Utf8("GET")'
-/// Using scan options ParquetScanOptions { pushdown_filters: false, reorder_predicates: false, enable_page_index: false }
-/// Iteration 0 returned 10699521 rows in 1303 ms
-/// Iteration 1 returned 10699521 rows in 1288 ms
-/// Iteration 2 returned 10699521 rows in 1266 ms
-/// Using scan options ParquetScanOptions { pushdown_filters: true, reorder_predicates: true, enable_page_index: true }
-/// Iteration 0 returned 1781686 rows in 1970 ms
-/// Iteration 1 returned 1781686 rows in 2002 ms
-/// Iteration 2 returned 1781686 rows in 1988 ms
-/// Using scan options ParquetScanOptions { pushdown_filters: true, reorder_predicates: false, enable_page_index: true }
-/// Iteration 0 returned 1781686 rows in 1940 ms
-/// Iteration 1 returned 1781686 rows in 1986 ms
-/// Iteration 2 returned 1781686 rows in 1947 ms
-/// ...
-#[derive(Debug, StructOpt, Clone)]
-#[structopt(verbatim_doc_comment)]
-pub struct RunOpt {
- /// Common options
- #[structopt(flatten)]
- common: CommonOpt,
-
- /// Create data files
- #[structopt(flatten)]
- access_log: AccessLogOpt,
-
- /// Path to machine readable output file
- #[structopt(parse(from_os_str), short = "o", long = "output")]
- output_path: Option<PathBuf>,
-}
-
-impl RunOpt {
- pub async fn run(self) -> Result<()> {
- let test_file = self.access_log.build()?;
-
- let mut rundata = BenchmarkRun::new();
- let scan_options_matrix = vec![
- ParquetScanOptions {
- pushdown_filters: false,
- reorder_filters: false,
- enable_page_index: false,
- },
- ParquetScanOptions {
- pushdown_filters: true,
- reorder_filters: true,
- enable_page_index: true,
- },
- ParquetScanOptions {
- pushdown_filters: true,
- reorder_filters: true,
- enable_page_index: false,
- },
- ];
-
- let filter_matrix = vec![
- ("Selective-ish filter", col("request_method").eq(lit("GET"))),
- (
- "Non-selective filter",
- col("request_method").not_eq(lit("GET")),
- ),
- (
- "Basic conjunction",
- col("request_method")
- .eq(lit("POST"))
- .and(col("response_status").eq(lit(503_u16))),
- ),
- (
- "Nested filters",
- col("request_method").eq(lit("POST")).and(or(
- col("response_status").eq(lit(503_u16)),
- col("response_status").eq(lit(403_u16)),
- )),
- ),
- (
- "Many filters",
- disjunction([
- col("request_method").not_eq(lit("GET")),
- col("response_status").eq(lit(400_u16)),
- col("service").eq(lit("backend")),
- ])
- .unwrap(),
- ),
- ("Filter everything", col("response_status").eq(lit(429_u16))),
- ("Filter nothing", col("response_status").gt(lit(0_u16))),
- ];
-
- for (name, filter_expr) in &filter_matrix {
- println!("Executing '{name}' (filter: {filter_expr})");
- for scan_options in &scan_options_matrix {
- println!("Using scan options {scan_options:?}");
- rundata.start_new_case(&format!(
- "{name}: {}",
- parquet_scan_disp(scan_options)
- ));
- for i in 0..self.common.iterations {
- let config = self.common.update_config(scan_options.config());
- let ctx = SessionContext::new_with_config(config);
-
- let (rows, elapsed) = exec_scan(
- &ctx,
- &test_file,
- filter_expr.clone(),
- self.common.debug,
- )
- .await?;
- let ms = elapsed.as_secs_f64() * 1000.0;
- println!("Iteration {i} returned {rows} rows in {ms} ms");
- rundata.write_iter(elapsed, rows);
- }
- }
- println!("\n");
- }
- rundata.maybe_write_json(self.output_path.as_ref())?;
- Ok(())
- }
-}
-
-fn parquet_scan_disp(opts: &ParquetScanOptions) -> String {
- format!(
- "pushdown_filters={}, reorder_filters={}, page_index={}",
- opts.pushdown_filters, opts.reorder_filters, opts.enable_page_index
- )
-}
-
-async fn exec_scan(
- ctx: &SessionContext,
- test_file: &TestParquetFile,
- filter: Expr,
- debug: bool,
-) -> Result<(usize, std::time::Duration)> {
- let start = Instant::now();
- let exec = test_file.create_scan(ctx, Some(filter)).await?;
-
- let task_ctx = ctx.task_ctx();
- let result = collect(exec, task_ctx).await?;
- let elapsed = start.elapsed();
- if debug {
- pretty::print_batches(&result)?;
- }
- let rows = result.iter().map(|b| b.num_rows()).sum();
- Ok((rows, elapsed))
-}
diff --git a/benchmarks/src/sort.rs b/benchmarks/src/sort.rs
deleted file mode 100644
index cbbd3b54ea..0000000000
--- a/benchmarks/src/sort.rs
+++ /dev/null
@@ -1,193 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-use std::path::PathBuf;
-use std::sync::Arc;
-
-use crate::util::{AccessLogOpt, BenchmarkRun, CommonOpt};
-
-use arrow::util::pretty;
-use datafusion::common::Result;
-use datafusion::physical_expr::{LexOrdering, PhysicalSortExpr};
-use datafusion::physical_plan::collect;
-use datafusion::physical_plan::sorts::sort::SortExec;
-use datafusion::prelude::{SessionConfig, SessionContext};
-use datafusion::test_util::parquet::TestParquetFile;
-use datafusion_common::instant::Instant;
-use datafusion_common::utils::get_available_parallelism;
-use structopt::StructOpt;
-
-/// Test performance of sorting large datasets
-///
-/// This test sorts a a synthetic dataset generated during the
-/// benchmark execution, designed to simulate sorting web server
-/// access logs. Such sorting is often done during data transformation
-/// steps.
-///
-/// The tests sort the entire dataset using several different sort
-/// orders.
-///
-/// Example:
-///
-/// dfbench sort --path ./data --scale-factor 1.0
-#[derive(Debug, StructOpt, Clone)]
-#[structopt(verbatim_doc_comment)]
-pub struct RunOpt {
- /// Common options
- #[structopt(flatten)]
- common: CommonOpt,
-
- /// Create data files
- #[structopt(flatten)]
- access_log: AccessLogOpt,
-
- /// Path to machine readable output file
- #[structopt(parse(from_os_str), short = "o", long = "output")]
- output_path: Option<PathBuf>,
-}
-
-impl RunOpt {
- pub async fn run(self) -> Result<()> {
- let test_file = self.access_log.build()?;
-
- use datafusion::physical_expr::expressions::col;
- let mut rundata = BenchmarkRun::new();
- let schema = test_file.schema();
- let sort_cases = vec![
- (
- "sort utf8",
- [PhysicalSortExpr {
- expr: col("request_method", &schema)?,
- options: Default::default(),
- }]
- .into(),
- ),
- (
- "sort int",
- [PhysicalSortExpr {
- expr: col("response_bytes", &schema)?,
- options: Default::default(),
- }]
- .into(),
- ),
- (
- "sort decimal",
- [PhysicalSortExpr {
- expr: col("decimal_price", &schema)?,
- options: Default::default(),
- }]
- .into(),
- ),
- (
- "sort integer tuple",
- [
- PhysicalSortExpr {
- expr: col("request_bytes", &schema)?,
- options: Default::default(),
- },
- PhysicalSortExpr {
- expr: col("response_bytes", &schema)?,
- options: Default::default(),
- },
- ]
- .into(),
- ),
- (
- "sort utf8 tuple",
- [
- // sort utf8 tuple
- PhysicalSortExpr {
- expr: col("service", &schema)?,
- options: Default::default(),
- },
- PhysicalSortExpr {
- expr: col("host", &schema)?,
- options: Default::default(),
- },
- PhysicalSortExpr {
- expr: col("pod", &schema)?,
- options: Default::default(),
- },
- PhysicalSortExpr {
- expr: col("image", &schema)?,
- options: Default::default(),
- },
- ]
- .into(),
- ),
- (
- "sort mixed tuple",
- [
- PhysicalSortExpr {
- expr: col("service", &schema)?,
- options: Default::default(),
- },
- PhysicalSortExpr {
- expr: col("request_bytes", &schema)?,
- options: Default::default(),
- },
- PhysicalSortExpr {
- expr: col("decimal_price", &schema)?,
- options: Default::default(),
- },
- ]
- .into(),
- ),
- ];
- for (title, expr) in sort_cases {
- println!("Executing '{title}' (sorting by: {expr:?})");
- rundata.start_new_case(title);
- for i in 0..self.common.iterations {
- let config = SessionConfig::new().with_target_partitions(
- self.common
- .partitions
- .unwrap_or_else(get_available_parallelism),
- );
- let ctx = SessionContext::new_with_config(config);
- let (rows, elapsed) =
- exec_sort(&ctx, &expr, &test_file, self.common.debug).await?;
- let ms = elapsed.as_secs_f64() * 1000.0;
- println!("Iteration {i} finished in {ms} ms");
- rundata.write_iter(elapsed, rows);
- }
- println!("\n");
- }
- if let Some(path) = &self.output_path {
- std::fs::write(path, rundata.to_json())?;
- }
- Ok(())
- }
-}
-
-async fn exec_sort(
- ctx: &SessionContext,
- expr: &LexOrdering,
- test_file: &TestParquetFile,
- debug: bool,
-) -> Result<(usize, std::time::Duration)> {
- let start = Instant::now();
- let scan = test_file.create_scan(ctx, None).await?;
- let exec = Arc::new(SortExec::new(expr.clone(), scan));
- let task_ctx = ctx.task_ctx();
- let result = collect(exec, task_ctx).await?;
- let elapsed = start.elapsed();
- if debug {
- pretty::print_batches(&result)?;
- }
- let rows = result.iter().map(|b| b.num_rows()).sum();
- Ok((rows, elapsed))
-}
diff --git a/benchmarks/src/util/access_log.rs b/benchmarks/src/util/access_log.rs
deleted file mode 100644
index 2b29465ee2..0000000000
--- a/benchmarks/src/util/access_log.rs
+++ /dev/null
@@ -1,74 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-//! Benchmark data generation
-
-use datafusion::common::Result;
-use datafusion::test_util::parquet::TestParquetFile;
-use parquet::file::properties::WriterProperties;
-use std::path::PathBuf;
-use structopt::StructOpt;
-use test_utils::AccessLogGenerator;
-
-// Options and builder for making an access log test file
-// Note don't use docstring or else it ends up in help
-#[derive(Debug, StructOpt, Clone)]
-pub struct AccessLogOpt {
- /// Path to folder where access log file will be generated
- #[structopt(parse(from_os_str), required = true, short = "p", long = "path")]
- path: PathBuf,
-
- /// Data page size of the generated parquet file
- #[structopt(long = "page-size")]
- page_size: Option<usize>,
-
- /// Data page size of the generated parquet file
- #[structopt(long = "row-group-size")]
- row_group_size: Option<usize>,
-
- /// Total size of generated dataset. The default scale factor of 1.0 will generate a roughly 1GB parquet file
- #[structopt(long = "scale-factor", default_value = "1.0")]
- scale_factor: f32,
-}
-
-impl AccessLogOpt {
- /// Create the access log and return the file.
- ///
- /// See [`TestParquetFile`] for more details
- pub fn build(self) -> Result<TestParquetFile> {
- let path = self.path.join("logs.parquet");
-
- let mut props_builder = WriterProperties::builder();
-
- if let Some(s) = self.page_size {
- props_builder = props_builder
- .set_data_page_size_limit(s)
- .set_write_batch_size(s);
- }
-
- if let Some(s) = self.row_group_size {
- props_builder = props_builder.set_max_row_group_size(s);
- }
- let props = props_builder.build();
-
- let generator = AccessLogGenerator::new();
-
- let num_batches = 100_f32 * self.scale_factor;
-
- TestParquetFile::try_new(path, props, generator.take(num_batches as usize))
- }
-}
diff --git a/benchmarks/src/util/mod.rs b/benchmarks/src/util/mod.rs
index 420d52401c..eb9a0b8bc9 100644
--- a/benchmarks/src/util/mod.rs
+++ b/benchmarks/src/util/mod.rs
@@ -16,10 +16,8 @@
// under the License.
//! Shared benchmark utilities
-mod access_log;
mod options;
mod run;
-pub use access_log::AccessLogOpt;
pub use options::CommonOpt;
pub use run::{BenchQuery, BenchmarkRun, QueryResult};