xudong963 commented on code in PR #21637: URL: https://github.com/apache/datafusion/pull/21637#discussion_r3165226806
########## datafusion/datasource-parquet/benches/parquet_fully_matched_filter.rs: ########## @@ -0,0 +1,292 @@ +// 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 for skipping filter evaluation on fully matched row groups. +//! +//! This benchmark measures the performance improvement from skipping +//! RowFilter evaluation when row group statistics prove that all rows +//! in a row group satisfy the predicate. +//! +//! Dataset layout: +//! - 20 row groups, each with 50_000 rows +//! - Column `x`: i64, values in range [0, 100) for all row groups +//! - Column `payload`: Utf8, 1 KB string (makes filter column decoding cost visible) +//! +//! Predicate: `x < 200` +//! - ALL row groups are fully matched (max(x) < 200 for every row group) +//! - Without the optimization: RowFilter decodes `x` and evaluates predicate for every row +//! - With the optimization: RowFilter is skipped entirely (statistics prove all rows match) +//! +//! Uses `ParquetPushDecoder` directly to exercise the exact code path +//! that DataFusion's async opener uses. + +use std::path::PathBuf; +use std::sync::{Arc, LazyLock}; + +use arrow::array::{Int64Array, RecordBatch, StringBuilder}; +use arrow::datatypes::{DataType, Field, Schema, SchemaRef}; +use bytes::Bytes; +use criterion::{Criterion, Throughput, criterion_group, criterion_main}; +use datafusion_common::ScalarValue; +use datafusion_datasource_parquet::{ParquetFileMetrics, build_row_filter}; +use datafusion_expr::{Expr, col}; +use datafusion_physical_expr::planner::logical2physical; +use datafusion_physical_plan::metrics::ExecutionPlanMetricsSet; +use parquet::DecodeResult; +use parquet::arrow::arrow_reader::ArrowReaderMetadata; +use parquet::arrow::push_decoder::ParquetPushDecoderBuilder; +use parquet::file::properties::WriterProperties; +use parquet::{arrow::ArrowWriter, file::metadata::ParquetMetaData}; +use tempfile::TempDir; + +const ROW_GROUP_SIZE: usize = 50_000; +const NUM_ROW_GROUPS: usize = 20; +const TOTAL_ROWS: usize = ROW_GROUP_SIZE * NUM_ROW_GROUPS; +const PAYLOAD_LEN: usize = 1024; + +struct BenchmarkDataset { Review Comment: yes, this one https://github.com/apache/datafusion/pull/21945 Do you think we should remove the current bench code in the PR? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
