Repository navigation
flow: a Partition's pieces stay on their worker (PR 3 of the plan) - #178
Merged
Merged
Conversation
A TaskMany submitted with remote_many(..., keep_on_worker=True) stores every result on its worker whatever its size, so it spills instead of sitting in the head's memory; a flow's Partition sets it. The flag is the top bit of the result count in the task-many, task-after and task-inputs frames, so frames without it are byte-identical to before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017TycsyUqdnuDeZrYc3z6wV
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017TycsyUqdnuDeZrYc3z6wV
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017TycsyUqdnuDeZrYc3z6wV
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 3 of the plan "Keyed partitions in flows" (DESIGN.md): a
Partition's pieces stay on the worker that made them whatever their size, so a shuffle of many small pieces sits in the workers' stores (which spill), not in the head's memory.What was built
remote_many(..., keep_on_worker=False): a keyword-only argument on all three forms ofClient.remote_manyandRuntime.remote_many. Every existing call is unchanged;Partition.submit_manypassesTrue.TaskMany's result count (KEEP_ON_WORKER = 1 << 63,dista/frame.mojo, withmany_word/parse_many), in task-many, task-after (MANY) and task-inputs (MANY). That count is the one field every frame that runs aTaskManycarries; task-many has no flags byte, and a trailing field would follow an argument with no length. The count is at most 2^20, so the bit was always 0: frames without the flag are byte-identical to before._Task.keep) and writes it into the count of the task-many / task-inputs frame it sends the worker, so a retry on another worker keeps it; a task-many frame goes on as it came. The driver's kept submission payload (Client._subs) has it, so a re-send after a head restart does too.Worker._finish), node store then spill dir, like a large one. An empty result still goes inline (the store can't map an empty file); aSeqnever encodes empty.Gate and evidence
2,000 pieces of 10 KB, the head's memory doesn't grow with them (
tests/test_partition_keep.mojo,test_kept_pieces_stay_off_the_head): deterministic check on the head's stats once all pieces exist: without the flagresults=2000, located=0, with itresults=0, located=2000. Head RSS growth from its start, printed (not asserted):Also a flow: 125 inputs × 16 pieces, one reducer at a time; at the first partition's result the head holds
results=1, located=1875; result exact.Store room for a quarter of the pieces (
test_pieces_past_the_store_spill_and_are_removed,DISTA_STORE_BYTES= pieces' bytes / 4 / 4 workers, large batches so partition tasks run from task-inputs): ~470 in the store and ~1,480 spilled at the first result, exact, store and spill dir empty after.No flag, same bytes (
test_a_program_without_the_flag_sends_the_bytes_it_sent_before): eachremote_manyform's frame read off a socket pair compared byte for byte with the pre-flag layout written out by hand; with the flag only the top bit differs, and the re-send copy matches. Head relay tests (test_the_head_passes_the_flag_on_and_keeps_it_for_a_retry,test_task_inputs_carry_the_flag) drive aHeadin-process: the flag reaches the worker in task-many and task-inputs, and survives a retry on another worker; without it the count is as before.Verified
test_partition_keep7 runs, all pass;test_flow_partition,test_flow,test_shuffle,test_spill; the changed partition-death test 5 more times alone;tests/flow_loss.sh×2,tests/head_restart.sh×2,tests/compile_fail.sh,format-check, and the fullpixi run testonce (exit 0).test_partition_keep×6,test_flow_partition,test_flow,test_spill, the partition-death test ×5,flow_loss.sh×2,head_restart.sh×2. All pass. Clone removed afterwards.Deviations (also in DESIGN.md, "PR 3, as built")
test_a_partition_task_whose_worker_dies_reads_its_input_againexpected exactly 1 rerun; it now flaked at 2 and expects ≥ 1 withsubmitted == INPUTS + reruns.FlowStats.unsized_piecesuntil its worker reports (head_restart.sh's partition flow shows 4)._run_many's three-copies peak untouched.For PR 4/5
A kept piece costs a file write each, and a reducer on another host now fetches each piece from its worker rather than getting small ones inline from the head (416 small fetches per reducer on AWS). Worth measuring in PR 5.
🤖 Generated with Claude Code
https://claude.ai/code/session_017TycsyUqdnuDeZrYc3z6wV