Skip to content
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

perf: Improve query planning to more reliably fall back to columnar shuffle when native shuffle is not supported #1209

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

andygrove
Copy link
Member

@andygrove andygrove commented Jan 1, 2025

Which issue does this PR close?

Closes #1208

Rationale for this change

For TPC-H q16, Comet was falling back to Spark shuffle when native shuffle was not supported, rather than falling back to Comet Columnar Shuffle.

Here are timings for 5 runs of q16:

Main Branch

        8.683910131454468,
        5.513509511947632,
        5.432432174682617,
        5.3881542682647705,
        5.4192214012146

This PR

        7.142122745513916,
        4.547697067260742,
        4.491749048233032,
        4.41376256942749,
        4.348492383956909

What changes are included in this PR?

Improve query planning logic to try native first, then columnar, then Spark.

The original code had separate match arms for native shuffle and columnar shuffle. If the native shuffle arm was chosen and then it was determined that the input plan was not native, we would fall back to Spark.

The new code has a single match arm that tries native first, then columnar, before falling back to Spark.

How are these changes tested?

@andygrove andygrove force-pushed the choose-better-shuffle branch from 2540893 to a1d5dc9 Compare January 1, 2025 18:29
@andygrove andygrove changed the title perf: Choose better shuffle perf: Improve query planning to more reliably fall back to columnar shuffle when native shuffle is not supported Jan 1, 2025
@andygrove andygrove marked this pull request as ready for review January 1, 2025 18:49
@andygrove andygrove marked this pull request as draft January 1, 2025 20:19
Comment on lines -813 to -814
case s: ShuffleExchangeExec
if isCometShuffleEnabled(conf) && isCometJVMShuffleMode(conf) &&
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, if it is auto mode, why this is not triggered?

Copy link
Member Author

Choose a reason for hiding this comment

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

This part is triggered, but in the following code, transform1(s) returns None so we return the original shuffle.

          val newOp = transform1(s)
          newOp match {
            case Some(nativeOp) =>
              // Switch to use Decimal128 regardless of precision, since Arrow native execution
              // doesn't support Decimal32 and Decimal64 yet.
              conf.setConfString(CometConf.COMET_USE_DECIMAL_128.key, "true")
              val cometOp = CometShuffleExchangeExec(s, shuffleType = CometNativeShuffle)
              CometSinkPlaceHolder(nativeOp, s, cometOp)
            case None =>
              s
          }

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.

Optimize TPC-H q16 to use columnar shuffle rather than native shuffle
2 participants