Skip to content

bench/shuffle: the runs on sai and their write-up (PR 5 of the plan) - #180

Merged
winding-lines merged 6 commits into
mainfrom
shuffle-flow-runs
Nov 29, 2026
Merged

winding-lines merged 6 commits into
mainfrom
shuffle-flow-runs

Conversation

@winding-lines

Copy link
Copy Markdown
Contributor

PR 5, the last PR of the plan "Keyed partitions in flows" (DESIGN.md): the measured runs on sai and what they found. On one machine, the same group-by runs three ways: as a flow, as the hand-written dista shuffle, and on Ray. The runs cover 8 and 16 workers of one slot each, PARTS 16 and 64, 3 passes each, and a run of the flow with a small store. The results are in bench/shuffle/README.md under "Results", and every run is a row in bench/shuffle/results/2026-11-29-sai/runs.tsv.

The bars

Bar Verdict
Exact Passed. Every run is within 1e-9 of one process (largest difference 9.4e-14 to 9.9e-14). Every flow run is bit-identical to the hand-written version.
Flow within 15% of the hand-written time Failed. Median 1.21 to 1.25× as the bench is now built (cap change plus a Partition budget of 64). With dista's default budget of 4 it is 1.23 to 1.40×, and before this PR it was 1.30 to 1.34×.
No slower than Ray Passed. The flow takes 0.27 to 0.34 of Ray's time.
Memory within 10% Passed. Peak PSS is 1.05 to 1.07× the hand-written version's.
Bounded with a small store Passed. With 5 MB per worker, the store peaked at 37.7 MB against a 40 MB limit and 211 MB spilled. Workers' peaks did not grow, the result was exact, and the store and spill directories were empty afterwards.

What the gap was

  • The read's reserved slot cost an extra wave of reads at 8 workers. At most 7 streams ran on 8 workers, and 15 on 16.
  • The Partition's budget of 4 was the larger cost. While 4 files are waiting for or running their partition task, the read opens no stream, and slots stand idle after each wave of streams ends.
  • What is left, about 20%, is the flow's own work. Streams take 10 to 13% more slot time than the map tasks, and the partition tasks add 53 to 78 ms per file.

Changes

  • dista.flow: a read whose batches go straight to its Partition now opens a stream on every slot. FlowRun._needs_free_slot checks only the operators before the Partition. Flows without a Partition compile to what they did before. A new test in tests/test_flow_partition.mojo runs such a flow on one slot; before this change it raised.
    • Effect: 3 to 6% faster at 8 workers, neutral at 16 workers with a budget of 64, and 3 to 5% slower at 16 workers with the budget of 4.
  • The bench's budget is now set with -D SHUFFLE_SPLITS, default 64.
  • SHUFFLE_WORKERS sets the worker count of both dista programs, and the CPUs of a local Ray.
  • The runner: bench/shuffle/run.py, runs.sh, timeline.py and summarize.py. bench/runlib.py is bench/embed/run.py's sampler, moved out so both runners share it.
  • Docs: DESIGN.md has a "PR 5, as built" note, PR 5 marked done in the plan table, and a status line saying the plan is complete.

Follow-up for the maintainer to decide

Whether Partition's default budget of 4 should be raised. A larger budget lets the read keep every slot busy. It costs memory: up to the read's streams plus the budget, counted in inputs, of batches held before the barrier. Here that raised the store's peak from 230 to 263 MB.

Tested on the Mac

test_flow, test_flow_partition, flow_loss.sh, head_restart.sh and test_partition_keep all pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_017TycsyUqdnuDeZrYc3z6wV

winding-lines and others added 6 commits November 29, 2026 08:12
bench/runlib.py holds what bench/embed/run.py's sampler did, so the
shuffle runner shares it; SHUFFLE_WORKERS sets the workers of both dista
programs and a local Ray's CPUs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017TycsyUqdnuDeZrYc3z6wV
A Partition's task starts only once its input's stream has ended, and the
batches before it are held outside any budget, so a stream never waits for
it: the read no longer leaves a slot free for it. Flows without a
Partition, or with an operator in the read's group before it, are as they
were.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017TycsyUqdnuDeZrYc3z6wV
…ther builds

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017TycsyUqdnuDeZrYc3z6wV
The flow, the hand-written shuffle and Ray on sai, 8 and 16 workers,
PARTS 16 and 64, 3 passes each, and the flow with a small store; four
builds of the flow to separate the read's reserved slot from the
Partition's budget. The bench's budget is now 64. Results in
bench/shuffle/README.md and bench/shuffle/results/2026-11-29-sai; PR 5
marked done and the plan complete in DESIGN.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017TycsyUqdnuDeZrYc3z6wV
@winding-lines
winding-lines merged commit 5d163eb into main Nov 29, 2026
12 checks passed
@winding-lines
winding-lines deleted the shuffle-flow-runs branch November 29, 2026 17:27
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.

1 participant