Skip to content

Conversation

@andygrove
Copy link
Member

@andygrove andygrove commented Sep 17, 2025

Which issue does this PR close?

N/A

Rationale for this change

I would like to make it easier to see what % of operators are accelerated by Comet.

What changes are included in this PR?

Add some basic statistics to the "extended explain" output to show % of operators accelerated by Comet.

Example output:

BroadcastHashJoin
:- ColumnarToRow
:  +-  Scan parquet  [COMET: Dynamic Partition Pruning is not supported]
:        +- SubqueryBroadcast
:           +- ReusedExchange
+- BroadcastExchange
   +- CometColumnarToRow
      +- CometFilter
         +- CometScan [native_iceberg_compat] parquet 

Comet accelerated 33% of eligible operators (sparkOperators=4, cometOperators=2, transitions=2, wrappers=1).

How are these changes tested?

Manually

@codecov-commenter
Copy link

codecov-commenter commented Sep 17, 2025

Codecov Report

❌ Patch coverage is 71.79487% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.54%. Comparing base (f09f8af) to head (6436574).
⚠️ Report is 567 commits behind head on main.

Files with missing lines Patch % Lines
...n/scala/org/apache/comet/ExtendedExplainInfo.scala 71.05% 6 Missing and 5 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2412      +/-   ##
============================================
+ Coverage     56.12%   58.54%   +2.41%     
- Complexity      976     1445     +469     
============================================
  Files           119      146      +27     
  Lines         11743    13534    +1791     
  Branches       2251     2356     +105     
============================================
+ Hits           6591     7923    +1332     
- Misses         4012     4379     +367     
- Partials       1140     1232      +92     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@andygrove
Copy link
Member Author

Subset of output from benchmarks

Reading query 16 using path /mnt/bigdata/tpch/queries//q16.sql
Comet accelerated 87% of eligible operators (sparkOperators=1, cometOperators=7, transitions=0, wrappers=0).
Comet accelerated 84% of eligible operators (sparkOperators=4, cometOperators=22, transitions=0, wrappers=0).
Comet accelerated 80% of eligible operators (sparkOperators=4, cometOperators=17, transitions=0, wrappers=0).
Comet accelerated 75% of eligible operators (sparkOperators=1, cometOperators=3, transitions=0, wrappers=0).
Comet accelerated 100% of eligible operators (sparkOperators=0, cometOperators=3, transitions=0, wrappers=0).
Comet accelerated 84% of eligible operators (sparkOperators=4, cometOperators=22, transitions=1, wrappers=0).
Comet accelerated 84% of eligible operators (sparkOperators=4, cometOperators=22, transitions=1, wrappers=0).
Comet accelerated 75% of eligible operators (sparkOperators=2, cometOperators=6, transitions=1, wrappers=0).

--conf spark.comet.explain.enabled=true \
--conf spark.memory.offHeap.enabled=true \
--conf spark.memory.offHeap.size=16g
--conf spark.memory.offHeap.size=2g
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated change, but we don't need 16g for this simple example

@andygrove andygrove marked this pull request as ready for review September 17, 2025 18:12
@andygrove andygrove marked this pull request as draft September 17, 2025 18:29
@andygrove andygrove marked this pull request as ready for review September 17, 2025 18:36

withSQLConf(CometConf.COMET_EXPLAIN_VERBOSE_ENABLED.key -> "true") {
val extendedExplain = new ExtendedExplainInfo().generateExtendedInfo(cometPlan)
assert(extendedExplain.contains("Comet accelerated 33% of eligible operators"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be this number fluctuating?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is currently stable across all Spark versions that we test with.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wrong. There is a failure due to a different percentage. I will make the test less specific.

- DPP fallback *** FAILED *** (1 second, 553 milliseconds)
  "BroadcastHashJoin
  :- ColumnarToRow
  :  +-  Scan parquet  [COMET: Dynamic Partition Pruning is not supported]
  :        +- SubqueryBroadcast
  :           +- BroadcastExchange
  :              +- CometColumnarToRow
  :                 +- CometFilter
  :                    +- CometScan [native_iceberg_compat] parquet 
  +- BroadcastExchange
     +- CometColumnarToRow
        +- CometFilter
           +- CometScan [native_iceberg_compat] parquet 
  
  Comet accelerated 4 out of 9 eligible operators (44%). Final plan contains 3 transitions between Spark and Comet." did not contain "Comet accelerated 33% of eligible operators" (CometExecSuite.scala:124)

@comphead
Copy link
Contributor

Comet accelerated 33% of eligible operators (sparkOperators=4, cometOperators=2, transitions=2, wrappers=1).

From the user perspective it might be not very clear what is accelerated?
When seeing message first time, I thought all of them are accelerated?

 (sparkOperators=4, cometOperators=2, transitions=2, wrappers=1).

which is not the case?

@andygrove andygrove marked this pull request as draft September 18, 2025 01:12
@andygrove
Copy link
Member Author

Comet accelerated 33% of eligible operators (sparkOperators=4, cometOperators=2, transitions=2, wrappers=1).

From the user perspective it might be not very clear what is accelerated? When seeing message first time, I thought all of them are accelerated?

 (sparkOperators=4, cometOperators=2, transitions=2, wrappers=1).

which is not the case?

Thanks, I will add documentation as part of this PR

var transitions: Int = 0

override def toString: String = {
s"sparkOperators=$sparkOperators, cometOperators=$cometOperators, " +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we could use a more verbose string here so that the meaning of these stats is a little more obvious

@parthchandra
Copy link
Contributor

We could potentially add a method to get the plan stats independent of the explain string too. I can see this being useful in writing some tool to analyse queries/plans without executing them.

@andygrove andygrove marked this pull request as ready for review September 29, 2025 19:55
@andygrove
Copy link
Member Author

Thanks for the reviews @comphead and @parthchandra. Could you take another look?

Copy link
Contributor

@parthchandra parthchandra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. Minor improvement suggested. Also, is the comment re the unit test addressed?

@andygrove
Copy link
Member Author

Thanks for the reviews @parthchandra @comphead. I have addressed feedback and plan on merging this later today, unless you have any other feedback

@andygrove andygrove merged commit ca2e611 into apache:main Oct 1, 2025
102 checks passed
@andygrove andygrove deleted the extended-explain-stats branch October 1, 2025 20:10
coderfender pushed a commit to coderfender/datafusion-comet that referenced this pull request Dec 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants