Plan conflict-free write batches for mismatched chunk grids - #324
Open
d-v-b wants to merge 2 commits into
Open
Conversation
Preserve source tasks, schedule destination write-unit conflicts, and expose explicit preserve/reorder policies. Include adversarial property tests, real concurrent codec copies, documentation, and comparisons with Dask and Rechunker planners. Assisted-by: Codex:GPT-6
Assisted-by: Codex:GPT-6
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.
🤖 AI text below 🤖
Incoming chunks can write disjoint array slices yet race when the destination performs read-modify-write on shared chunks or shards. This PR adds
plan_rechunkto keep each source chunk as one task and schedule batches with disjoint destination write units. For chunks of 3 copied into chunks of 4 over length 12, the schedule is((0, 2), (1, 3)).plan_write_batcheshandles existing request-to-destination transforms. Its default preserves input order between conflicting tasks; explicitorder="reorder"uses deterministic first-fit coloring. The scheduler tracks per-unit state without constructing a pairwise conflict graph. Plans contain task/piece metadata and perform no I/O.This is stacked on
zarr-indexing/grid-partition, independent of the separate execution-prototype PR.Contracts and limits
plan_chunkstransform combinations remain unsupported.Comparison and adversarial review
The guide compares the utility with Rechunker, Dask task rechunking, and Xarray alignment checks. The benchmark script was run with Dask 2026.8.0 and Rechunker 0.5.4 in an isolated environment. It distinguishes explicit schedule assignments from external planners' transfer-layout descriptions rather than presenting unlike constructor times as a throughput comparison.
The 100-task misaligned case schedules in four batches. Row-to-column copying needs 128 serial batches when source rows stay intact; Rechunker instead selects
(4, 128)reads,(4, 4)intermediate blocks, and(128, 4)writes under the tested 4 KiB budget. This limitation is documented rather than hidden behind a coloring heuristic.Independent adversarial review checked 5,000 resource-set schedules against a reference first-fit algorithm, 4,000 transform footprint cases against point enumeration (unsupported mixed transforms excluded explicitly), and 1,500 irregular-grid source-selection reconstructions. Review corrections include explicit transform limitations, complete runnable snippet imports, and correctly named Rechunker output fields.
Validation