lyne7-sc commented on code in PR #24589:
URL: https://github.com/apache/datafusion/pull/24589#discussion_r3879299151


##########
datafusion/physical-plan/benches/window_filter.rs:
##########
@@ -0,0 +1,263 @@
+// 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.
+
+//! Microbenchmark for window aggregates with `FILTER`. The benchmark uses
+//! pre-ordered input to exclude sorting and query planning, but executes the
+//! physical window plan so both stateful and whole-partition evaluation paths
+//! are represented.
+
+use std::hint::black_box;
+use std::sync::Arc;
+
+use arrow::array::{BooleanArray, Float64Array, UInt64Array};
+use arrow::datatypes::{DataType, Field, Schema, SchemaRef};
+use arrow::record_batch::RecordBatch;
+use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
+use datafusion_common::{ScalarValue, config::ConfigOptions};
+use datafusion_execution::TaskContext;
+use datafusion_expr::{
+    Operator, WindowFrame, WindowFrameBound, WindowFrameUnits, 
WindowFunctionDefinition,
+};
+use datafusion_functions::math::power;
+use datafusion_functions_aggregate::sum::sum_udaf;
+use datafusion_physical_expr::expressions::{BinaryExpr, col, lit};
+use datafusion_physical_expr::{
+    LexOrdering, PhysicalExpr, PhysicalSortExpr, ScalarFunctionExpr,
+};
+use datafusion_physical_plan::test::TestMemoryExec;
+use datafusion_physical_plan::windows::{
+    BoundedWindowAggExec, WindowAggExec, create_window_expr,
+};
+use datafusion_physical_plan::{ExecutionPlan, InputOrderMode, collect};
+
+const BATCH_SIZE: usize = 8192;
+const NUM_BATCHES: usize = 4;
+
+#[derive(Clone, Copy)]
+enum ArgumentKind {
+    Column,
+    Divide,
+    Power,
+}
+
+impl ArgumentKind {
+    fn name(self) -> &'static str {
+        match self {
+            Self::Column => "column",
+            Self::Divide => "divide",
+            Self::Power => "power_udf",
+        }
+    }
+}
+
+fn schema() -> SchemaRef {
+    Arc::new(Schema::new(vec![
+        Field::new("id", DataType::UInt64, false),
+        Field::new("value", DataType::Float64, false),
+        Field::new("include", DataType::Boolean, false),
+    ]))
+}
+
+fn make_batches(filter_percent: usize) -> Vec<RecordBatch> {
+    (0..NUM_BATCHES)
+        .map(|batch_index| {
+            let start = batch_index * BATCH_SIZE;
+            let end = start + BATCH_SIZE;
+            let id = UInt64Array::from_iter_values((start..end).map(|i| i as 
u64));
+            let value = Float64Array::from_iter_values((start..end).map(|i| i 
as f64));
+            let include = BooleanArray::from(
+                (start..end)
+                    .map(|i| (i * filter_percent) % 100 < filter_percent)

Review Comment:
   Thanks again for the feedback. I took a closer look, and whether the 
selected rows are clustered or scattered does not seem to change the 
window-specific evaluation or accumulator work. The layout can still affect 
Arrow's filter kernel, but that feels like a separate dimension from what this 
benchmark is intended to isolate.
   
   Should we keep this benchmark focused on the window FILTER path? I think we 
can adjust the existing include distribution so that it has a mix of isolated 
and consecutive selected rows. Would that address your concern?



-- 
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]

Reply via email to