Skip to content

[Data]Implement Join on hash shuffle v2 - #64538

Merged
edoakes merged 19 commits into
ray-project:masterfrom
owenowenisme:data/join-on-shuffle-reduce
Jul 11, 2026
Merged

edoakes merged 19 commits into
ray-project:masterfrom
owenowenisme:data/join-on-shuffle-reduce

Conversation

@owenowenisme

@owenowenisme owenowenisme commented Jul 4, 2026 •

Copy link
Copy Markdown
Member

Description

Implement joins on top of the shuffle v2, no additional tests added because we're using the old test.

Related issues

Link related issues: "Fixes #1234", "Closes #1234", or "Related to #1234".

Additional information

Optional: Add implementation details, API changes, usage examples, screenshots, etc.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the shuffle execution framework to support multi-input shuffle reduce operations, enabling a new V2 shuffle-based join implementation. Key changes include modifying ShuffleReduceOp to accept multiple upstream ShuffleMapOp inputs, updating the reduce task to process lists of tables grouped by input, and planning joins using the new shuffle path. The review feedback highlights a critical issue where incremental_resource_usage underestimates peak memory for multi-input shuffles by only considering the first dependency, which could lead to out-of-memory errors. Additionally, defensive checks are recommended in hash_shuffle_v2.py to prevent potential IndexErrors when accessing tables_by_input.

Generalize ShuffleReduceOp / _shuffle_reduce_task to N co-partitioned inputs (pairing per (partition, input), all-inputs-done flush, tables_by_input). This is now based on master after ray-project#64481, so the PR carries only multi-input support and not the streaming-reduce removal.

Signed-off-by: You-Cheng Lin <[email protected]>
Signed-off-by: You-Cheng Lin <[email protected]>
Signed-off-by: You-Cheng Lin <[email protected]>
@owenowenisme
owenowenisme force-pushed the data/join-on-shuffle-reduce branch from dccf2a9 to 720d787 Compare July 8, 2026 03:56
owenowenisme and others added 3 commits July 8, 2026 11:15
…fle-reduce

# Conflicts:
#	python/ray/data/_internal/execution/operators/hash_shuffle_v2.py
#	python/ray/data/_internal/execution/operators/shuffle_operators/shuffle_reduce_operator.py
#	python/ray/data/tests/test_hash_shuffle_v2.py
Signed-off-by: You-Cheng Lin <[email protected]>
(cherry picked from commit bb429a4)
@owenowenisme owenowenisme added data Ray Data-related issues go add ONLY when ready to merge, run all tests labels Jul 9, 2026
@owenowenisme
owenowenisme marked this pull request as ready for review July 9, 2026 22:06
@owenowenisme
owenowenisme requested a review from a team as a code owner July 9, 2026 22:06
assert op0_output == op1_input


def test_sub_operator_num_rows(shutdown_only):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Removing this because we don't have sub operator in join after this pr

return tables


@ray.remote(max_calls=1)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Removing this because worker restart can have huge regression with small dataset & inadequate resource.
The OOM of shuffle previously is mainly from mixing shuffle map tasks and other tasks not from reducer. So this is fine

@owenowenisme

Copy link
Copy Markdown
Member Author

@cursor review

@owenowenisme owenowenisme changed the title [Data][WIP] Implement Join on hash shuffle v2 [Data]Implement Join on hash shuffle v2 Jul 9, 2026
Signed-off-by: You-Cheng Lin <[email protected]>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit fd3f539. Configure here.

@edoakes
edoakes self-requested a review July 10, 2026 01:51
@owenowenisme

Copy link
Copy Markdown
Member Author

Ran the TPC-H q21 release test since its workload is heavier.

tpch21: 453.3s → 408.2s (≈10% runtime reduction)

The gain is modest here because memory isn't a bottleneck in this test and the aggregation still runs on v1 shuffle. We expect a larger improvement once aggregation on v2 lands as well.

@edoakes edoakes left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM, only stylistic comments. My only hesitation is if we should first enable it off-by-default until we validate with some users. The baseline stability of the existing join/hash shuffle is a bit suspect though, so personally I'm OK with turning this on by default from the get-go assuming that release tests are stable.

@goutamvenkat-anyscale @bveeramani LMK what you think.

Signed-off-by: You-Cheng Lin <[email protected]>
Signed-off-by: You-Cheng Lin <[email protected]>
Signed-off-by: You-Cheng Lin <[email protected]>
@owenowenisme
owenowenisme force-pushed the data/join-on-shuffle-reduce branch from 0eb06e7 to 953cf2f Compare July 10, 2026 21:17
@edoakes
edoakes merged commit 05adf45 into ray-project:master Jul 11, 2026
3 checks passed
bveeramani pushed a commit that referenced this pull request Jul 16, 2026
…orker kill on map_groups_autoscaling release test (#64737)

## Description
The `map_groups_autoscaling_hash_shuffle_*` nightly release test started
failing with worker OOM kills on `_shuffle_reduce_task`, beginning after
#64538, which removed setting `max_calls=1` on the remote task to
alleviate the performance regressions on join tests.
In order to circumvent this issue, we can give reduce tasks their own
dedicated worker pool via `runtime_env`

We isolate the shuffle reduce tasks into running on their own pool of
workers (mirroring the same isolation done on the shuffle map tasks in
https://github.com/ray-project/ray/blob/bb3934d01ca5bd4c88cc66326a32e7c364ffeff9/python/ray/data/_internal/execution/operators/hash_shuffle_v2.py#L15)
## Related issues

## Additional information

---------

Signed-off-by: Ayush Kumar <[email protected]>
400Ping pushed a commit to 400Ping/ray that referenced this pull request Aug 18, 2026
## Description
Implement joins on top of the shuffle v2, no additional tests added
because we're using the old test.

## Related issues
> Link related issues: "Fixes ray-project#1234", "Closes ray-project#1234", or "Related to
ray-project#1234".

## Additional information
> Optional: Add implementation details, API changes, usage examples,
screenshots, etc.

---------

Signed-off-by: You-Cheng Lin <[email protected]>
Signed-off-by: You-Cheng Lin <[email protected]>
Signed-off-by: 400Ping <[email protected]>
400Ping pushed a commit to 400Ping/ray that referenced this pull request Aug 18, 2026
…orker kill on map_groups_autoscaling release test (ray-project#64737)

## Description
The `map_groups_autoscaling_hash_shuffle_*` nightly release test started
failing with worker OOM kills on `_shuffle_reduce_task`, beginning after
ray-project#64538, which removed setting `max_calls=1` on the remote task to
alleviate the performance regressions on join tests.
In order to circumvent this issue, we can give reduce tasks their own
dedicated worker pool via `runtime_env`

We isolate the shuffle reduce tasks into running on their own pool of
workers (mirroring the same isolation done on the shuffle map tasks in
https://github.com/ray-project/ray/blob/bb3934d01ca5bd4c88cc66326a32e7c364ffeff9/python/ray/data/_internal/execution/operators/hash_shuffle_v2.py#L15)
## Related issues

## Additional information

---------

Signed-off-by: Ayush Kumar <[email protected]>
Signed-off-by: 400Ping <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data Ray Data-related issues go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ray fails to serialize self-reference objects

2 participants