Skip to content

Experiment: immediate-mode shuffle #3855

Closed

Description

@andygrove

What is the problem the feature request solves?

I have been experimenting with "immediate mode" shuffle, where we immediately repartition batches using interleave record batches to produce small batches per output partition and then use a BatchCoalescer to combine these small batches into larger batches before encoding.

I am creating this issue to capture lessons learned.

Describe the potential solution

No response

Additional context

No response

Activity

  1. self-assigned this
    on Mar 31, 2026
  2. andygrove commented on Mar 31, 2026

    @andygrove
    MemberAuthor

    The main issue I am running into with this approach is higher peak memory due to allocator churn due to interleave creating so many small arrays. This approach uses 2x the peak memory of the buffered approach.

  3. added this to the 0.15.0 milestone on Mar 31, 2026
  4. andygrove commented on Mar 31, 2026

    @andygrove
    MemberAuthor

    Gluten follows this approach:

    • Pre-allocate one set of column buffers per partition
    • Scatter-write rows from each input batch directly into partition buffers using raw pointers
    • Accumulate across multiple input batches until buffers fill
    • Evict (flush) full buffers and reuse the allocation
    • Only resize when the estimated size changes beyond a threshold

    This avoids a lot of intermediate allocations.

  5. wForget commented on Apr 3, 2026

    @wForget
    Member

    If I understand correctly, the current proposal is similar to gluten's hash shuffle writer (default behavior).

    • buffered-mode shuffle is similar to gluten's sort shuffle writer: insert batch -> add batches to a global buffer -> spilt by pid and evict to partition writer
    • immediate-mode shuffle is similar to gluten's hash shuffle writer: insert batch -> spilt and push to partition buffers -> evict partition buffer to parititon writer

    According to the performance report at apache/gluten#6475, the performance of the two shuffle modes may be related to the number of partitions.

  6. added
    priority:lowMinor issues, test failures, tooling, cosmetic
    and removed on Apr 18, 2026
  7. modified the milestones: 0.15.0, 0.16.0 on Apr 25, 2026
  8. andygrove commented on Apr 25, 2026

    @andygrove
    MemberAuthor

    I am closing this as completed, since we did this experiment. Although it has benefits in some cases, it does not scale well with large number of output partitions due to the need to maintain builders or batch coalesces per output partition.

  9. moved this to In progress in Comet Developmenton May 6, 2026
  10. moved this from In progress to Done in Comet Developmenton May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestpriority:lowMinor issues, test failures, tooling, cosmetic

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions