Repository navigation
bench/shuffle: the group-by as a flow (PR 4 of the keyed-partitions plan) - #179
Merged
Merged
Conversation
…lan) deploy/shuffle_flow.mojo runs the shuffle benchmark's query as Flow[Read[ScanGroups], Partition[SplitZones, PARTS], Reduce[MergeZones]], one input per data file. Its stream puts each batch's keys with the file's running totals, so the partition task keeps each key's last totals and the answer is the hand-written version's to the last bit, at 16 and 64 partitions. PARTS is set when building (-D SHUFFLE_PARTS); the data environment's build-shuffle task builds build/shuffle and build/shuffle-flow-16 and -64, and the data job in CI runs it. The row code both programs share moves to deploy/zone_hours.mojo; deploy/shuffle.mojo prints what it printed before. TAXI_MODE=both in the flow program checks it against one process and the hand-written shuffle, and it prints the flow's stats after its last pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017TycsyUqdnuDeZrYc3z6wV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR 4 of the plan "Keyed partitions in flows (plan, 2026-11-29)" in
DESIGN.md.What was built
deploy/shuffle_flow.mojo: the shuffle benchmark's group-by asFlow[Read[ScanGroups], Partition[SplitZones, PARTS], Reduce[MergeZones]], one input per data file. The stream reads a file a batch at a time into running totals per key and puts one item per batch: that batch's keys with the file's totals so far. The partition task keeps each key's last totals, which are the file's, and splits them bykey % PARTS. The reducer is the hand-written one. Running totals keep the sums in the hand-written map task's order, so the flow'sANSWERandTOPlines are the hand-written version's to the last bit.deploy/zone_hours.mojo: the code both programs share, moved out ofdeploy/shuffle.mojo: features, key, groups, top 10, map and reduce tasks, one-process run, check and printing. Its private names are now public, it gainsDense.add_counted, anddistributedis generic over the runtime.deploy/shuffle.mojois now itsmainalone, and prints what it printed before.PARTSat build time: set with-D SHUFFLE_PARTS=<n>(default 16).pixi run -e data build-shuffle(bench/shuffle/build.sh) buildsbuild/shuffle,build/shuffle-flow-16andbuild/shuffle-flow-64.SHUFFLE_REDUCERS, if set, must match the binary'sPARTS.TAXI_MODEs as the hand-written version.bothchecks the flow against one process and, in the same process, against the hand-written shuffle withPARTSreducers, and prints aDIFFline for each. The program prints the sameTIME zone_hours <pass> <ms>lines, andSTATS zone_hours …(the flow'sstats()) after the last pass.bench/shuffle/README.mdgains an "As a flow" section and run lines,DESIGN.mdgets "PR 4, as built" and PR 4 marked done, andCHANGELOG.mdone line.Nothing in
src/dista/changed.Verified (macOS, the shared Mac mini, local table of 24 files)
TAXI_MODE=bothwithbuild/shuffle-flow-16andbuild/shuffle-flow-64: PASS. Against the hand-written shuffle the largest relative difference is 0 (bit-identical). Against one process it is 9.4e-14 at 16 and 9.9e-14 at 64; counts and top-10 keys are exact and the sums are within the bench's 1e-9. The hand-written version isn't bit-identical to one process either, because the process's threads add files in another order. TheANSWER/TOPlines of the flow equalbuild/shuffle's withSHUFFLE_REDUCERS16 and 64.TAXI_MODE=bothat 16 and 64. ItsANSWER/TOPlines equal those of a build oforigin/main'sdeploy/shuffle.mojo.TAXI_MODE=localworks, and a mismatchedSHUFFLE_REDUCERSgives the build hint.pixi run test-shuffle,test-flow-partitionandtest-flowpass, as dopixi run -e fmt format-checkand customs v0.5.1.Deviations (details in "PR 4, as built")
Read[ScanGroups, 64], so the workers' slots set the stream count and not the default 4.bothalso runs the hand-written version, to check against it.First look at time (single runs of 5 passes, shared Mac, 4 workers; not PR 5's numbers)
The flow is 33 to 40% slower at one slot per worker. Most of that is the read's cap, which keeps one slot free for the tasks after it: the flow reads 3 files at a time on 4 one-slot workers, where the hand-written version runs 4 map tasks. Its streams used about the same slot time, 3.40 s against the hand-written map tasks' 3.47 s. The partition tasks add 0.44 s on the free slot, 18 ms a file.
🤖 Generated with Claude Code
https://claude.ai/code/session_017TycsyUqdnuDeZrYc3z6wV