0lai0 commented on code in PR #5614:
URL: https://github.com/apache/datafusion-comet/pull/5614#discussion_r3931157120


##########
spark/src/test/scala/org/apache/spark/sql/benchmark/CometSequenceBenchmark.scala:
##########
@@ -0,0 +1,68 @@
+/*
+ * 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
+
+/**
+ * Benchmark to measure performance of Comet's native `sequence` kernel 
against Spark's codegen
+ * (issue #5349). Integral shapes run natively under Comet; the date case 
stays on the JVM codegen
+ * dispatcher in both arms and is included to show that path is unchanged. To 
run this benchmark:
+ * {{{
+ *   SPARK_GENERATE_BENCHMARK_FILES=1 make 
benchmark-org.apache.spark.sql.benchmark.CometSequenceBenchmark
+ * }}}
+ * Results will be written to 
"spark/benchmarks/CometSequenceBenchmark-**results.txt".
+ */
+object CometSequenceBenchmark extends CometBenchmarkBase {
+
+  private val sequenceQueries = List(
+    ("seq_short_5_elems", "SELECT sequence(c_start, c_start + 4) FROM 
parquetV1Table"),
+    ("seq_spine_365_elems", "SELECT sequence(c_start, c_start + 364) FROM 
parquetV1Table"),

Review Comment:
   Thanks for the feedback, I pushed the fix. 
   Stop endpoints are now materialized columns (`c_stop_5`, `c_stop_365`, 
`c_stop_10000`, `c_null_stop_365`), so every integral query passes only 
literals and column references and satisfies 
`CometSequence.argsAreLiteralsOrRefs` 
(`spark/src/main/scala/org/apache/comet/serde/arrays.scala:957`). The date case 
keeps the arithmetic form intentionally, because temporal `Sequence` 
unconditionally routes through the JVM dispatcher (`arrays.scala:948-952`); it 
stays in the list as the dispatcher control.
   
   Benchmark on Apple M5 / OpenJDK 17.0.18, 8192 rows:
   
   | case | Spark ns/row | Comet ns/row | Comet vs Spark |
   | --- | ---: | ---: | ---: |
   | seq_short_5_elems | 1795 | 645 | 2.8× |
   | seq_spine_365_elems | 1796 | 798 | 2.3× |
   | seq_long_10000_elems | 7922 | 7135 | 1.1× |
   | seq_descending_default_step | 1746 | 736 | 2.4× |
   | seq_explicit_step_7 | 1421 | 489 | 2.9× |
   | seq_sparse_nulls_365_elems | 1651 | 663 | 2.5× |
   | seq_date_spine_dispatcher (control) | 1528 | 1554 | 1.0× |
   
   The integral vs date gap (2–3× vs ~1.0×) is the path evidence: leaf-arg 
queries now hit native; the date control stays on the dispatcher. The old 
`c_start + 4` shape would have been ~1.0× across the board because 
`argsAreLiteralsOrRefs` rejected it.
   
   Dropped a plan-text `spark_sequence` check, that name only appears in the 
native proto, so it always reported `native=false`. Operator-level Comet 
coverage is already asserted by `findFirstNonCometOperator`; the timings cover 
the expression path.



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