Repository navigation
[Data] Pin fused map function for shuffle tasks - #65480
Conversation
There was a problem hiding this comment.
Code Review
This pull request optimizes ShuffleTaskSpec by storing the upstream_map_fn in the Ray object store via ray.put during initialization, preventing redundant serialization. A corresponding unit test was added to verify this behavior. The reviewer noted that the mock upstream_map_fn in the new test is defined and called with two arguments, whereas the production signature only uses a single argument, and suggested updating the test to align with the production usage.
2c8ed37 to
0a2a763
Compare
There was a problem hiding this comment.
Hey thanks for contribution. I think the change is reasonable and this is a real bug, however this path (what we call shuffle v1) is slated for removal in an upcoming release, so I wouldn't invest more time optimizing here.
I'll approve since the fix is real and low risk, but can you drop the test as other tests is already sufficient for that?
Store the fused upstream map function once in the object store and pass its ObjectRef as a top-level shuffle task argument. This avoids serializing large UDF closures for every shuffle map submission. Signed-off-by: viiccwen <[email protected]>
0a2a763 to
ad3e125
Compare
Thanks for feedback, I've removed it. |
|
@viiccwen please check the failed tests |
Not caused by this PR. |
## Description Store a fused upstream map function once in Ray's object store when constructing `ShuffleTaskSpec`, then pass its `ObjectRef` as a top-level positional argument to pull- and push-based shuffle-map tasks. On `master`, the function is stored directly in `map_args` and serialized with every task submission. Large captured UDF state therefore consumes object-store memory approximately in proportion to the number of shuffle-map tasks. ### Benchmark Compared `master` against this branch using 500,000 rows and 4 local CPUs. Every measured sample launched a fresh Ray process, asserted an already-fused physical plan, ran a fixed 0 MiB-closure warm-up, and timed only the measured Dataset materialization. Master and fix samples were alternated in A/B/A/B order, with 10 independent samples per revision and case. | Case | Master median | Fix median | Ratio | Master IQR | Fix IQR | Master peak | Fix peak | | --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | | Pull random shuffle, 10 MiB | `0.121s` | `0.074s` | `1.64x` | `0.119-0.132s` | `0.066-0.086s` | `104.0 MiB` | `13.9 MiB` | | Pull random shuffle, 25 MiB | `0.187s` | `0.102s` | `1.84x` | `0.185-0.194s` | `0.086-0.108s` | `254.0 MiB` | `28.9 MiB` | | Pull random shuffle, 50 MiB | `0.384s` | `0.113s` | `3.41x` | `0.320-0.409s` | `0.099-0.147s` | `504.0 MiB` | `53.9 MiB` | | Pull random shuffle, 100 MiB | `0.640s` | `0.155s` | `4.11x` | `0.490-0.690s` | `0.134-0.186s` | `1004.0 MiB` | `103.9 MiB` | | Pull repartition, 100 MiB | `0.426s` | `0.150s` | `2.83x` | `0.407-0.512s` | `0.127-0.239s` | `1004.0 MiB` | `103.9 MiB` | | Push random shuffle, 100 MiB | `1.873s` | `0.146s` | `12.84x` | `1.411-2.485s` | `0.133-0.160s` | `1011.2 MiB` | `111.2 MiB` | | Push repartition, 100 MiB | `1.527s` | `0.130s` | `11.78x` | `1.349-2.056s` | `0.120-0.139s` | `1011.2 MiB` | `111.2 MiB` | ## Related issues closes ray-project#65479. ## Additional information > Optional: Add implementation details, API changes, usage examples, screenshots, etc. Signed-off-by: viiccwen <[email protected]> Co-authored-by: You-Cheng Lin <[email protected]>
Add a nomination under `fellowship/ray/` Suggested level: 30k Highlights from 2026-09-01 to 2026-10-11: - [Contribution](https://github.com/opensource4you/readme/blob/main/fellowship/ray/fellow-contribution/viiccwen/September/report.md) - Merged 10 Ray Data PRs and filed 8 issues in 6 weeks - Made shuffle tasks up to 12.84x faster by pinning the fused map function, so large UDF closures are no longer serialized again for every shuffle task ([#65480](ray-project/ray#65480)) - Built a memory observability series to help users avoid OOM: exported task peak USS and logical memory metrics with Grafana charts ([#65666](ray-project/ray#65666), [#66044](ray-project/ray#66044)), added a warning with a suggested memory value when it is set below 1.25x max USS ([#65512](ray-project/ray#65512)), and updated the OOM prevention docs ([#65509](ray-project/ray#65509)) - Found, reported and fixed silent data loss in hash-shuffle (V2) anti joins, where rows were dropped when the other side was empty and had an unknown schema ([#66126](ray-project/ray#66126)) - Reviewed other fellows' PRs with suggestions ([#66878](ray-project/ray#66878)) - Merged the most PRs and filed the most issues of all Ray Fellowship participants - Solid work for an early contributor
Description
Store a fused upstream map function once in Ray's object store when constructing
ShuffleTaskSpec, then pass itsObjectRefas a top-level positional argument to pull- and push-based shuffle-map tasks.On
master, the function is stored directly inmap_argsand serialized with every task submission. Large captured UDF state therefore consumes object-store memory approximately in proportion to the number of shuffle-map tasks.Benchmark
Compared
masteragainst this branch using 500,000 rows and 4 local CPUs. Every measured sample launched a fresh Ray process, asserted an already-fused physical plan, ran a fixed 0 MiB-closure warm-up, and timed onlythe measured Dataset materialization. Master and fix samples were alternated in A/B/A/B order, with 10 independent samples per revision and case.
0.121s0.074s1.64x0.119-0.132s0.066-0.086s104.0 MiB13.9 MiB0.187s0.102s1.84x0.185-0.194s0.086-0.108s254.0 MiB28.9 MiB0.384s0.113s3.41x0.320-0.409s0.099-0.147s504.0 MiB53.9 MiB0.640s0.155s4.11x0.490-0.690s0.134-0.186s1004.0 MiB103.9 MiB0.426s0.150s2.83x0.407-0.512s0.127-0.239s1004.0 MiB103.9 MiB1.873s0.146s12.84x1.411-2.485s0.133-0.160s1011.2 MiB111.2 MiB1.527s0.130s11.78x1.349-2.056s0.120-0.139s1011.2 MiB111.2 MiBRelated issues
closes #65479.
Additional information