-
Notifications
You must be signed in to change notification settings - Fork 303
perf: avoid JVM shuffle when sandwiched between non-Comet operators [WIP] #4010
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
andygrove
wants to merge
7
commits into
apache:main
Choose a base branch
from
andygrove:avoid-jvm-shuffle-for-jvm-parent
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
994189c
refactor: coordinate shuffle path checks through a single entry point
andygrove 6b7e322
docs: clarify withInfo is for fallback reasons; restore sort-order ro…
andygrove cee98e3
chore: trigger CI
andygrove 11e11d6
feat: avoid JVM shuffle when sandwiched between non-Comet operators
andygrove 013fd95
Merge remote-tracking branch 'apache/main' into avoid-jvm-shuffle-for…
andygrove ca831d1
fix: narrow revert-to-Spark-shuffle match to HashAggregate parents
andygrove c856b23
fix: tag reverted shuffle so AQE stage re-planning does not reintrodu…
andygrove File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 63 additions & 64 deletions
127
...rces/tpcds-plan-stability/approved-plans-v1_4-spark3_5/q10.native_datafusion/extended.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,67 +1,66 @@ | ||
| TakeOrderedAndProject | ||
| +- HashAggregate | ||
| +- CometNativeColumnarToRow | ||
| +- CometColumnarExchange | ||
| +- HashAggregate | ||
| +- Project | ||
| +- BroadcastHashJoin | ||
| :- Project | ||
| : +- BroadcastHashJoin | ||
| : :- Project | ||
| : : +- Filter | ||
| : : +- BroadcastHashJoin | ||
| : : :- BroadcastHashJoin | ||
| : : : :- BroadcastHashJoin | ||
| : : : : :- CometNativeColumnarToRow | ||
| : : : : : +- CometFilter | ||
| : : : : : +- CometNativeScan parquet spark_catalog.default.customer | ||
| : : : : +- BroadcastExchange | ||
| : : : : +- Project | ||
| : : : : +- BroadcastHashJoin | ||
| : : : : :- ColumnarToRow | ||
| : : : : : +- Scan parquet spark_catalog.default.store_sales [COMET: Native DataFusion scan does not support subqueries/dynamic pruning] | ||
| : : : : : +- SubqueryBroadcast | ||
| : : : : : +- BroadcastExchange | ||
| : : : : : +- CometNativeColumnarToRow | ||
| : : : : : +- CometProject | ||
| : : : : : +- CometFilter | ||
| : : : : : +- CometNativeScan parquet spark_catalog.default.date_dim | ||
| : : : : +- BroadcastExchange | ||
| : : : : +- CometNativeColumnarToRow | ||
| : : : : +- CometProject | ||
| : : : : +- CometFilter | ||
| : : : : +- CometNativeScan parquet spark_catalog.default.date_dim | ||
| : : : +- BroadcastExchange | ||
| : : : +- Project | ||
| : : : +- BroadcastHashJoin | ||
| : : : :- ColumnarToRow | ||
| : : : : +- Scan parquet spark_catalog.default.web_sales [COMET: Native DataFusion scan does not support subqueries/dynamic pruning] | ||
| : : : : +- ReusedSubquery | ||
| : : : +- BroadcastExchange | ||
| : : : +- CometNativeColumnarToRow | ||
| : : : +- CometProject | ||
| : : : +- CometFilter | ||
| : : : +- CometNativeScan parquet spark_catalog.default.date_dim | ||
| : : +- BroadcastExchange | ||
| : : +- Project | ||
| : : +- BroadcastHashJoin | ||
| : : :- ColumnarToRow | ||
| : : : +- Scan parquet spark_catalog.default.catalog_sales [COMET: Native DataFusion scan does not support subqueries/dynamic pruning] | ||
| : : : +- ReusedSubquery | ||
| : : +- BroadcastExchange | ||
| : : +- CometNativeColumnarToRow | ||
| : : +- CometProject | ||
| : : +- CometFilter | ||
| : : +- CometNativeScan parquet spark_catalog.default.date_dim | ||
| : +- BroadcastExchange | ||
| : +- CometNativeColumnarToRow | ||
| : +- CometProject | ||
| : +- CometFilter | ||
| : +- CometNativeScan parquet spark_catalog.default.customer_address | ||
| +- BroadcastExchange | ||
| +- CometNativeColumnarToRow | ||
| +- CometProject | ||
| +- CometFilter | ||
| +- CometNativeScan parquet spark_catalog.default.customer_demographics | ||
| +- Exchange | ||
| +- HashAggregate | ||
| +- Project | ||
| +- BroadcastHashJoin | ||
| :- Project | ||
| : +- BroadcastHashJoin | ||
| : :- Project | ||
| : : +- Filter | ||
| : : +- BroadcastHashJoin | ||
| : : :- BroadcastHashJoin | ||
| : : : :- BroadcastHashJoin | ||
| : : : : :- CometNativeColumnarToRow | ||
| : : : : : +- CometFilter | ||
| : : : : : +- CometNativeScan parquet spark_catalog.default.customer | ||
| : : : : +- BroadcastExchange | ||
| : : : : +- Project | ||
| : : : : +- BroadcastHashJoin | ||
| : : : : :- ColumnarToRow | ||
| : : : : : +- Scan parquet spark_catalog.default.store_sales [COMET: Native DataFusion scan does not support subqueries/dynamic pruning] | ||
| : : : : : +- SubqueryBroadcast | ||
| : : : : : +- BroadcastExchange | ||
| : : : : : +- CometNativeColumnarToRow | ||
| : : : : : +- CometProject | ||
| : : : : : +- CometFilter | ||
| : : : : : +- CometNativeScan parquet spark_catalog.default.date_dim | ||
| : : : : +- BroadcastExchange | ||
| : : : : +- CometNativeColumnarToRow | ||
| : : : : +- CometProject | ||
| : : : : +- CometFilter | ||
| : : : : +- CometNativeScan parquet spark_catalog.default.date_dim | ||
| : : : +- BroadcastExchange | ||
| : : : +- Project | ||
| : : : +- BroadcastHashJoin | ||
| : : : :- ColumnarToRow | ||
| : : : : +- Scan parquet spark_catalog.default.web_sales [COMET: Native DataFusion scan does not support subqueries/dynamic pruning] | ||
| : : : : +- ReusedSubquery | ||
| : : : +- BroadcastExchange | ||
| : : : +- CometNativeColumnarToRow | ||
| : : : +- CometProject | ||
| : : : +- CometFilter | ||
| : : : +- CometNativeScan parquet spark_catalog.default.date_dim | ||
| : : +- BroadcastExchange | ||
| : : +- Project | ||
| : : +- BroadcastHashJoin | ||
| : : :- ColumnarToRow | ||
| : : : +- Scan parquet spark_catalog.default.catalog_sales [COMET: Native DataFusion scan does not support subqueries/dynamic pruning] | ||
| : : : +- ReusedSubquery | ||
| : : +- BroadcastExchange | ||
| : : +- CometNativeColumnarToRow | ||
| : : +- CometProject | ||
| : : +- CometFilter | ||
| : : +- CometNativeScan parquet spark_catalog.default.date_dim | ||
| : +- BroadcastExchange | ||
| : +- CometNativeColumnarToRow | ||
| : +- CometProject | ||
| : +- CometFilter | ||
| : +- CometNativeScan parquet spark_catalog.default.customer_address | ||
| +- BroadcastExchange | ||
| +- CometNativeColumnarToRow | ||
| +- CometProject | ||
| +- CometFilter | ||
| +- CometNativeScan parquet spark_catalog.default.customer_demographics | ||
|
|
||
| Comet accelerated 21 out of 54 eligible operators (38%). Final plan contains 11 transitions between Spark and Comet. | ||
| Comet accelerated 20 out of 54 eligible operators (37%). Final plan contains 10 transitions between Spark and Comet. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the opttimzation @andygrove
I guess this is the first time where
CometShuffleExchangeExecis reverted back to a plainShuffleExchangeExec.The two shuffle paths use different memory systems:
Users who have tuned their clusters for Comet (smaller JVM heap) could see unexpected spills after this chang, shifting shuffle memory pressure back to theJVM.
Additionally, Comet's Arrow IPC columnar format typically compresses better than Spark's row-based UnsafeRowSerializer path, so shuffle I/O mayalso increase.
It would be good to document or log when a shuffle is reverted so users can correlate any unexpected behavior with this optimization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback @karuppayya. I'm assuming the cost of doing two transitions (r2c then c2r) would outweigh the benefits of using Comet shuffle? I agree that it would be worth adding documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that this optimization will improve performance and compute efficiency.
My main concern is determining the best recommendation for users to tune memory, particularly since they cannot explicitly disable it.
Also can it be a seperate rule in itself and have it only in
org.apache.comet.CometSparkSessionExtensions.CometExecColumnar#postColumnarTransitions?