Repository navigation
[Data] Make shuffle regroup operator the owner of flight server - #67143
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the disk-based hash shuffle implementation in Ray Data by replacing the custom DiskHashShuffleMapOp with a standard MapOperator that utilizes a new DiskShuffleWriteFn block transform. It also replaces the hardcoded _BLOCKING_MATERIALIZING_OPERATORS list with a dynamic is_blocking_materializing property on PhysicalOperator to streamline backpressure and resource allocation. Additionally, DiskHashShuffleReduceOp is updated to directly manage the lifecycle of ShuffleFileServer actors. The review feedback identifies two potential performance bottlenecks on the main executor thread: sequentially calling ray.get inside _add_input_inner and blocking the thread with a 5-second ray.wait timeout during teardown_disk_shuffle. It is recommended to batch the ray.get calls and make the directory cleanup asynchronous or fire-and-forget.
| if cleanup_refs: | ||
| ray.wait(cleanup_refs, num_returns=len(cleanup_refs), timeout=5.0) |
There was a problem hiding this comment.
Calling ray.wait with a 5-second timeout inside teardown_disk_shuffle blocks the main executor thread during operator shutdown. In scenarios where multiple datasets are running concurrently or sequentially on the same driver, blocking the executor thread for up to 5 seconds will pause all other active datasets.\n\nSince directory cleanup is a fire-and-forget operation, consider submitting the cleanup tasks without waiting for them to complete on the main thread, or offloading the wait to a background thread.
There was a problem hiding this comment.
Ig this could be turned into a fire and forget call. but could also be ok to leave it as it is as this is only affecting teardown
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Reviewed by Cursor Bugbot for commit 4bb30ca. Configure here.
|
This pull request has been automatically marked as stale because it has not had You can always ask for help on our discussion forum or Ray's public slack channel. If you'd like to keep this open, just leave any comment, and the stale label will be removed. |
| for server in self._file_servers.values(): | ||
| ray.kill(server, no_restart=True) | ||
| teardown_disk_shuffle(self._file_servers.keys()) |
There was a problem hiding this comment.
_file_servers only tracks nodes after the reducer receives their handles. If execution stops before that, these nodes won't be cleaned up, leaving .shf files on disk.
Maybe we can track mapper nodes separately to make sure the files are cleaned up even if execution stops early?
There was a problem hiding this comment.
Yeah I planned to deal with that in another PR, this one focus on the server.
There was a problem hiding this comment.
Since you add disk_shuffle_dirs, replace with _, staging_dir = disk_shuffle_dirs(shuffle_id).
Then remove unused import tempfile.
| if ( | ||
| isinstance(writer, TaskPoolMapOperator) | ||
| and len(writer._logical_operators) <= 1 | ||
| and writer.input_dependencies | ||
| ): | ||
| return writer.input_dependencies[0].num_output_rows_total() |
There was a problem hiding this comment.
The reducer seems to know too much about the upstream operator here, like checking TaskPoolMapOperator, accessing _logical_operators, and going through writer.input_dependencies[0].
Maybe we can let the planner pass the row count source directly, so the reducer doesn't need to depend on these implementation details.
But this would also require changing the upstream contract. WDYT?
Signed-off-by: You-Cheng Lin <[email protected]>
4bb30ca to
98dce74
Compare
Signed-off-by: You-Cheng Lin <[email protected]>
Signed-off-by: You-Cheng Lin <[email protected]>
…nto releases/2.61.0 (#68472) ## Description Cherry-pick of #68433 (`1729626bbb`) onto `releases/2.61.0`. Lets the upstream read or map fuse into the disk-shuffle writer, and sets the polars thread limit inside the task rather than through the runtime env. The pick applied without conflicts. Seven master commits that touch the same files are not on the release branch (#67143, #68158, #68202 and its revert #68383, #68319, #67570, #68118), so the picked files differ from master in five places. Reviewers from Data, please confirm none of those is a prerequisite. ## Testing Ran locally against the `releases/2.61.0` wheel (`7c8ca5ea51`) with the picked files overlaid: `test_hash_shuffle_v2.py`, `test_operator_fusion.py` and `test_execution_optimizer_advanced.py`, 232 passed, 2 skipped. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: You-Cheng Lin <[email protected]> Signed-off-by: elliot-barn <[email protected]> Co-authored-by: You-Cheng Lin <[email protected]>

Description
As title, with this we don't have to use detached actor for flight server.
Should rebase after #67130 merged
Related issues
Additional information