apache / datafusion-comet

Apache DataFusion Comet Spark Accelerator
https://datafusion.apache.org/comet
Apache License 2.0
829 stars 164 forks source link

[EPIC] Improve performance of TPC-H queries #391

Open andygrove opened 6 months ago

andygrove commented 6 months ago

What is the problem the feature request solves?

This epic is for tracking progress on improving performance of Comet with our benchmarks derived from TPC-H.

Current status (September 2024)

Screenshot 2024-09-20 at 10 08 15 AM

Features needed to support all queries natively

We do not run all queries fully natively yet due to these missing features:

Planned features that could help in general

Issues that affect multiple queries

Per-Query Tracking

Most of these queries are already faster with Comet enabled. Here are notes on areas where performance could potentially be improved.

viirya commented 6 months ago

BroadcastExchange should be supported, I think. We have CometBroadcastExchange.

We don't need to support AQEShuffleRead. It is a shuffle reader wrapper in Spark. It calls wrapped shuffle's execute or executeColumnar depending on it is columnar or not.

viirya commented 6 months ago

We don't need to support Execute CreateViewCommand too. It is a command exec operator.

viirya commented 6 months ago

Also CommandResult, which is only used to hold data from a command. CommandResult and Execute CreateViewCommand are not query execution operators.

andygrove commented 6 months ago

Also CommandResult, which is only used to hold data from a command. CommandResult and Execute CreateViewCommand are not query execution operators.

Thanks. I saw those from the CREATE VIEW in q15 but I see from the Spark UI that the SELECT part of this query is already fully native. I have removed those from the list.

andygrove commented 6 months ago

BroadcastExchange should be supported, I think. We have CometBroadcastExchange.

BroadcastExchange is not supported is the information that Comet provides for q8. I think part of this epic will be making these messages more informative.

viirya commented 6 months ago

For Sort merge join with a join condition, I added the support to DataFusion for a while but we've not incorporated the feature in Comet yet. I opened #398 to track it and I will work on it once #250 is merged and #248 is done.

viirya commented 6 months ago

BroadcastExchange is not supported is the information that Comet provides for q8. I think part of this epic will be making these messages more informative.

I will take a look at q8 and see why it is not enabled there.

andygrove commented 6 months ago

I will take a look at q8 and see why it is not enabled there.

The error BroadcastExchange is not supported really means BroadcastExchange is not supported because the child operators are not supported

viirya commented 6 months ago

Please disable spark.comet.exec.broadcast.enabled which should not be used in normal query: https://github.com/apache/datafusion-comet/issues/408#issuecomment-2104818958

mbutrovich commented 1 month ago

I ran TPC-H locally and profiled the sole executor with 4 CPU cores allocated to it. One thing I noticed is that update_comet_metric is taking 3.2% of the time. Within Native_executePlan it accounts for ~7-8% of an individual worker's CPU time in Comet.

I want to look at the granularity that these operations occur at, and see if we can coalesce metrics on the native side and maybe ship more at once to reduce the JNI overhead. I want to add more metrics to Comet to understand where we're spending time, but the overhead is going to add up.

tpch