backendArchitect commented on code in PR #7795:
URL: https://github.com/apache/datafusion-comet/pull/7795#discussion_r4749532232


##########
spark/src/test/scala/org/apache/spark/sql/benchmark/CometSkipPartialAvgBenchmark.scala:
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.
+ */
+
+package org.apache.spark.sql.benchmark
+
+import org.apache.spark.benchmark.Benchmark
+import org.apache.spark.sql.comet.CometHashAggregateExec
+import org.apache.spark.sql.comet.execution.shuffle.CometShuffleExchangeExec
+import org.apache.spark.sql.internal.SQLConf
+
+import org.apache.comet.CometConf
+
+/**
+ * Compare a high-cardinality `GROUP BY` with a decimal `AVG` with adaptive 
partial aggregation
+ * disabled and enabled. Use a native release build:
+ *
+ * {{{
+ * make benchmark-org.apache.spark.sql.benchmark.CometSkipPartialAvgBenchmark 
-- 8388608 5
+ * }}}
+ *
+ * Arguments are rows and iterations. The input is one file, read by one task, 
with two key
+ * layouts: `distinct`, where every key is distinct, and `repeating`, where 
the first eighth of
+ * the rows are distinct and then repeat seven more times, so skipping starts 
after the first
+ * 100,000 rows and shuffles every later row (#6466). Shuffle records and 
bytes come from an
+ * untimed execution.
+ */
+object CometSkipPartialAvgBenchmark extends CometBenchmarkBase {
+
+  private val query =
+    "SELECT sum(a), count(a) FROM (SELECT k, avg(d) a FROM parquetV1Table 
GROUP BY k)"
+
+  private def cometConf(skip: Boolean): Seq[(String, String)] = Seq(
+    CometConf.COMET_ENABLED.key -> "true",
+    CometConf.COMET_EXEC_ENABLED.key -> "true",
+    CometConf.COMET_SHUFFLE_ENABLED.key -> "true",
+    CometConf.COMET_SHUFFLE_MODE.key -> "native",
+    CometConf.COMET_EXEC_AGGREGATE_SKIP_PARTIAL_ENABLED.key -> skip.toString)
+
+  private def report(benchmark: Benchmark, layout: String, skip: Boolean): 
Unit = {
+    withSQLConf(cometConf(skip): _*) {
+      val plans = capturePlans(spark.sql(query).collect())
+      val shuffles = collectAcross(plans) { case e: CometShuffleExchangeExec 
=> e }
+      val aggregates = collectAcross(plans) { case a: CometHashAggregateExec 
=> a }
+      require(shuffles.nonEmpty && aggregates.nonEmpty, s"Expected a native 
plan:\n$plans")
+      val records = shuffles.map(_.metrics("shuffleRecordsWritten").value).sum
+      val bytes = shuffles.map(_.metrics("dataSize").value).sum

Review Comment:
   Agreed. I'll report `shuffleBytesWritten` (with `dataSize` as the input 
size) and assert that rows were skipped whenever skipping is on, then rerun and 
post the numbers, once we've settled the question above.



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