Skip to content

feat(shuffle): add row-based threshold option - #852

Merged
zhangxffff merged 1 commit into
bytedance:mainfrom
zhangxffff:feat/add_row_based_shuffle_threshold
Aug 13, 2026
Merged

feat(shuffle): add row-based threshold option#852
zhangxffff merged 1 commit into
bytedance:mainfrom
zhangxffff:feat/add_row_based_shuffle_threshold

Conversation

@zhangxffff

@zhangxffff zhangxffff commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

What problem does this PR solve?

Adaptive shuffle currently selects the row-based implementation only when both fixed thresholds are met: at least 8,000 partitions and at least 5 columns. This cannot represent workloads whose combined partition-column scale is large while either dimension remains below its fixed threshold.

This PR adds an opt-in product threshold so row-based shuffle can also be selected when numPartitions * numColumns exceeds a configurable value, while preserving the existing default behavior.

Issue Number: #853

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 🚀 Performance improvement (optimization)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)
  • 🔨 Refactoring (no logic changes)
  • 🔧 Build/CI or Infrastructure changes
  • 📝 Documentation only

Description

  • Add rowBasedShuffleThreshold to both ShuffleWriterOptions and ShuffleReaderOptions.
  • Preserve the existing adaptive selection rule:
    numPartitions >= 8000 && numColumns >= 5.
  • Add an alternative rule that selects row-based shuffle when
    numPartitions * numColumns > rowBasedShuffleThreshold.
  • Use int64_t for the product calculation to avoid 32-bit overflow.
  • Apply the same selection logic to the writer, SparkShuffleReader, and BoltColumnarBatchDeserializerFactory.
  • Propagate the reader option into the deserializer factory so the reader and writer make consistent wire-format decisions.
  • Default the new threshold to std::numeric_limits<int64_t>::max(), disabling the new rule unless explicitly configured.

The writer and reader must be configured with the same threshold to ensure they agree on the shuffle wire format.

Performance Impact

  • No Impact: This change does not affect the critical path (e.g., build system, doc, error handling).
  • Positive Impact: I have run benchmarks.
  • Negative Impact: Explained below (e.g., trade-off for correctness).

The default configuration preserves the existing shuffle selection behavior. The additional multiplication and comparison occur during writer or reader initialization rather than per row. Configuring the new threshold intentionally changes which shuffle implementation is selected.

Release Note

Release Note:
- Added a configurable partition-column product threshold for adaptive row-based shuffle selection while preserving existing defaults.

Checklist (For Author)

  • I have added/updated unit tests (ctest).
  • I have verified the code with local build (Release/Debug).
  • I have run clang-format / linters.
  • (Optional) I have run Sanitizers (ASAN/TSAN) locally for complex C++ changes.
  • No need to test or manual test.

Breaking Changes

  • No
  • Yes (Description: ...)

Keep the existing partition and column thresholds, and add a configurable partition-column product threshold for adaptive row-based shuffle selection.

Co-authored-by: TRAE CLI <noreply@bytedance.com>
@zhangxffff
zhangxffff added this pull request to the merge queue Aug 13, 2026
Merged via the queue into bytedance:main with commit 5aa5523 Aug 13, 2026
11 checks passed
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.

2 participants