damacy rewrite PR-1: file split + prefetcher producer#121
Open
nclack wants to merge 9 commits into
Open
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## worktree-prefetch #121 +/- ##
=====================================================
+ Coverage 58.21% 58.75% +0.54%
=====================================================
Files 56 60 +4
Lines 7948 8016 +68
Branches 1396 1400 +4
=====================================================
+ Hits 4627 4710 +83
+ Misses 2746 2743 -3
+ Partials 575 563 -12
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
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.
Reviewer: read
dev/damacy_rewrite_pr1.mdfirst. It's the load-bearing artifact — the function-by-function plan, the open questions, and the rationale for every decision.This is PR-1 of a multi-PR rewrite. PR-2 deletes the legacy zarr caches and rewires the planner; PR-3 updates Python tests + docs. PR-1 changes who produces samples for the planner, but the planner itself still uses the legacy
zarr_meta_cache/zarr_shard_cacheso this lands without touching decode.Glossary
damacy_internal.h.damacy_scheduler_stepfor one batch.prefetch_cacheinstances the prefetcher fills, keyed by uri / (uri, shard_coord) / uri respectively.pushed_samples / batch_size); the prefetcher groups in-flight samples by this key, andplan_reserveonly consumes terminal-state slots whose batch_id matches the next-to-plan batch.Summary
Splits monolithic
damacy.cinto focused TUs (commits 2–4: pure moves, no behavior change) then rewires the data flow so the prefetcher is the producer forplan_reserve(commits 5–7). The old path drained samples straight from the lookahead insideplan_reserve; the new path popsprefetcher_readyslots that have already cleared the array-meta / shard-index / chunk-layout fetches, and the scheduler gate becomesprefetcher_batch_full_ready(...)instead oflookahead.size >= batch_size.Where to look first after the plan doc:
src/damacy_plan.c(the newplan_reserve— that's the load-bearing behavioral change). Thensrc/damacy_lifecycle.cfor construction order (dedicated io_queue + 3 caches + 3 fetchers + prefetcher) andsrc/damacy_scheduler.cfor the gate swap.Non-obvious decisions worth a second look:
Plan commits 7 + 8 are merged (
damacy: producer is the prefetcher). The plan suggested splitting "rewire plan/scheduler" from "rewire pop/flush idle predicates" but the boundary isn't realizable — onceprefetcher_startruns, the worker drains the lookahead immediately, sodamacy_pop's oldlookahead.size < batch_sizeAGAIN gate fires before the prefetcher can finish. Both predicates must flip together.plan_reservesuppressesDAMACY_NOTFOUNDfrom the prefetcher's error path (seesrc/damacy_plan.cnear the staging loop). The legacy planner independently handles missing chunks via the array's fill_value; if both layers errored on NOTFOUND, every shard-deleted test would regress. PR-2 will revisit when the planner consumes prefetch handles directly.chunk_layoutreturns success/NULL for non-blosc codecs instead ofDAMACY_DECODE. The pre-existing code comment said "non-blosc arrays fall back to worst-case caps" but the code errored; aligning the code with the comment. Test renamed fromtest_non_blosc_codec_errors→test_non_blosc_codec_yields_no_layout.Prefetcher pop preserves push order via a new
admit_seqfield onstruct prefetcher_slot. The original scan-and-take loop inpop_terminal_slot_lockedwould return whichever slot finished its fetches first, swapping intra-batch sample order;admit_seqmakes pop deterministic.Three Python tests are
pytest.skip'd inpython/tests/test_damacy.py. They assert push-time URI / dtype / per-array-rank errors; those checks now surface at pop time. PR-3 rewrites them.Test plan
test_damacy,test_damacy_blosc,test_damacy_caps,test_damacy_ctx(31/31 passing on every commit in the series).test_multi_batchis the load-bearing one for the admission-order fix; withoutadmit_seqit shows mixed-quadrant data corruption.test_missing_shard_fillsexercises the NOTFOUND-suppression path inplan_reserve(the shard file isunlink'd so the prefetcher errors but the planner emits fill).