You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by ag...@apache.org on 2026/09/05 22:55:28 UTC
(datafusion-comet) branch main updated: fix: make columnar-to-row benchmarks exercise Comet (#5718)
This is an automated email from the ASF dual-hosted git repository.
andygrove pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion-comet.git
The following commit(s) were added to refs/heads/main by this push:
new f97fb4519c fix: make columnar-to-row benchmarks exercise Comet (#5718)
f97fb4519c is described below
commit f97fb4519cad2a4f6fe435d66aa17eacbd919a9b
Author: KUAN-HAO HUANG <10...@users.noreply.github.com>
AuthorDate: Sun Sep 6 06:55:23 2026 +0800
fix: make columnar-to-row benchmarks exercise Comet (#5718)
---
.../benchmark/CometColumnarToRowBenchmark.scala | 86 +++++++++++++++++-----
1 file changed, 67 insertions(+), 19 deletions(-)
diff --git a/spark/src/test/scala/org/apache/spark/sql/benchmark/CometColumnarToRowBenchmark.scala b/spark/src/test/scala/org/apache/spark/sql/benchmark/CometColumnarToRowBenchmark.scala
index 91db9796fa..22e7dbb54d 100644
--- a/spark/src/test/scala/org/apache/spark/sql/benchmark/CometColumnarToRowBenchmark.scala
+++ b/spark/src/test/scala/org/apache/spark/sql/benchmark/CometColumnarToRowBenchmark.scala
@@ -19,10 +19,15 @@
package org.apache.spark.sql.benchmark
+import scala.collection.mutable.ArrayBuffer
+
import org.apache.spark.SparkConf
import org.apache.spark.benchmark.Benchmark
import org.apache.spark.sql.SparkSession
+import org.apache.spark.sql.comet.{CometColumnarToRowExec, CometNativeColumnarToRowExec}
+import org.apache.spark.sql.execution.{ColumnarToRowExec, QueryExecution, SparkPlan}
import org.apache.spark.sql.internal.SQLConf
+import org.apache.spark.sql.util.QueryExecutionListener
import org.apache.comet.{CometConf, CometSparkSessionExtensions}
@@ -46,6 +51,9 @@ object CometColumnarToRowBenchmark extends CometBenchmarkBase {
.set("spark.master", "local[1]")
.setIfMissing("spark.driver.memory", "3g")
.setIfMissing("spark.executor.memory", "3g")
+ .set(
+ "spark.shuffle.manager",
+ "org.apache.spark.sql.comet.execution.shuffle.CometShuffleManager")
.set("spark.memory.offHeap.enabled", "true")
.set("spark.memory.offHeap.size", "2g")
@@ -61,6 +69,8 @@ object CometColumnarToRowBenchmark extends CometBenchmarkBase {
sparkSession.conf.set(SQLConf.WHOLESTAGE_CODEGEN_ENABLED.key, "true")
sparkSession.conf.set(CometConf.COMET_ENABLED.key, "false")
sparkSession.conf.set(CometConf.COMET_EXEC_ENABLED.key, "false")
+ // These fixtures are written by Spark and contain no unsigned small integers.
+ sparkSession.conf.set(CometConf.COMET_PARQUET_UNSIGNED_SMALL_INT_CHECK.key, "false")
// Disable dictionary encoding to ensure consistent data representation
sparkSession.conf.set("parquet.enable.dictionary", "false")
@@ -72,29 +82,67 @@ object CometColumnarToRowBenchmark extends CometBenchmarkBase {
* code duplication across benchmark methods.
*/
private def addC2RBenchmarkCases(benchmark: Benchmark, query: String): Unit = {
- benchmark.addCase("Spark (ColumnarToRowExec)") { _ =>
- withSQLConf(CometConf.COMET_ENABLED.key -> "false") {
- spark.sql(query).noop()
- }
- }
+ def addCase(name: String, expected: Class[_ <: SparkPlan], conf: (String, String)*): Unit = {
+ withSQLConf(conf: _*) {
+ // Validate the actual noop write, whose plan can differ from the SELECT's plan.
+ // Keep execution and listener synchronization outside the timed benchmark cases.
+ val plans = ArrayBuffer.empty[SparkPlan]
+ val listener = new QueryExecutionListener {
+ override def onSuccess(funcName: String, qe: QueryExecution, durationNs: Long): Unit = {
+ plans += qe.executedPlan
+ }
- benchmark.addCase("Comet JVM (CometColumnarToRowExec)") { _ =>
- withSQLConf(
- CometConf.COMET_ENABLED.key -> "true",
- CometConf.COMET_EXEC_ENABLED.key -> "true",
- CometConf.COMET_NATIVE_COLUMNAR_TO_ROW_ENABLED.key -> "false") {
- spark.sql(query).noop()
+ override def onFailure(
+ funcName: String,
+ qe: QueryExecution,
+ exception: Exception): Unit = ()
+ }
+ spark.sparkContext.listenerBus.waitUntilEmpty()
+ spark.listenerManager.register(listener)
+ try {
+ spark.sql(query).noop()
+ spark.sparkContext.listenerBus.waitUntilEmpty()
+ } finally {
+ spark.listenerManager.unregister(listener)
+ }
+ val conversions = plans.flatMap { plan =>
+ collect(plan) {
+ case c: ColumnarToRowExec => c
+ case c: CometColumnarToRowExec => c
+ case c: CometNativeColumnarToRowExec => c
+ }
+ }
+ require(
+ conversions.nonEmpty && conversions.forall(expected.isInstance),
+ s"$name did not execute the expected columnar-to-row conversion.\n" +
+ plans.mkString("\n"))
+ benchmark.out.println(s"Verified $name")
}
- }
-
- benchmark.addCase("Comet Native (CometNativeColumnarToRowExec)") { _ =>
- withSQLConf(
- CometConf.COMET_ENABLED.key -> "true",
- CometConf.COMET_EXEC_ENABLED.key -> "true",
- CometConf.COMET_NATIVE_COLUMNAR_TO_ROW_ENABLED.key -> "true") {
- spark.sql(query).noop()
+ benchmark.addCase(name) { _ =>
+ withSQLConf(conf: _*) {
+ spark.sql(query).noop()
+ }
}
}
+
+ addCase(
+ "Spark (ColumnarToRowExec)",
+ classOf[ColumnarToRowExec],
+ CometConf.COMET_ENABLED.key -> "false")
+
+ addCase(
+ "Comet JVM (CometColumnarToRowExec)",
+ classOf[CometColumnarToRowExec],
+ CometConf.COMET_ENABLED.key -> "true",
+ CometConf.COMET_EXEC_ENABLED.key -> "true",
+ CometConf.COMET_NATIVE_COLUMNAR_TO_ROW_ENABLED.key -> "false")
+
+ addCase(
+ "Comet Native (CometNativeColumnarToRowExec)",
+ classOf[CometNativeColumnarToRowExec],
+ CometConf.COMET_ENABLED.key -> "true",
+ CometConf.COMET_EXEC_ENABLED.key -> "true",
+ CometConf.COMET_NATIVE_COLUMNAR_TO_ROW_ENABLED.key -> "true")
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org