Skip to content

damacy rewrite: prefetcher producer + planner handles#121

Merged
nclack merged 19 commits into
worktree-prefetchfrom
damacy-rewrite
May 30, 2026
Merged

damacy rewrite: prefetcher producer + planner handles#121
nclack merged 19 commits into
worktree-prefetchfrom
damacy-rewrite

Conversation

@nclack
Copy link
Copy Markdown
Owner

@nclack nclack commented May 23, 2026

Summary

  • Split the monolithic damacy.c orchestrator into lifecycle, push, plan, pop, and scheduler modules.
  • Make the metadata prefetcher the producer for planning: pushed samples now flow through array metadata, shard index, and chunk-layout prefetch before plan_reserve.
  • Rewire the planner to consume prefetch handles directly, then delete the legacy synchronous zarr_meta_cache and zarr_shard_cache.
  • Preserve sparse-zarr behavior: genuinely missing shard files become fill chunks; IO, decode, permission, and malformed-shard errors still fail the sample.
  • Rename public cache tuning/stats to match the active caches: array_meta, shard_index, and chunk_layout.

Reviewer Notes

  • The most important files are src/damacy_plan.c, src/damacy_scheduler.c, src/prefetch/prefetcher.c, and src/planner/planner.c.
  • Store-derived validation now happens asynchronously. Missing URIs, unsupported source dtypes, per-array rank mismatch, and decode failures surface from pop(), not push().
  • Prefetcher pop order is stabilized with admit_seq, so batches preserve push order even when metadata fetches finish out of order.
  • Chunk-layout probing uses an actual ready shard touched by the sample rather than assuming the origin shard exists.
  • prefetch_handle moved to a small standalone header so CUDA-facing planner headers do not include prefetch_cache.h.

Tests

  • Focused C tests for planner/prefetch/cache behavior:
    env UV_CACHE_DIR=/tmp/uv-cache timeout 90s ctest --test-dir build -R 'test_(planner|chunk_layout_cache|prefetcher)$' --output-on-failure
  • damacy plus the focused test targets build successfully:
    cmake --build build --target damacy test_chunk_layout_cache test_prefetcher test_planner

@codecov
Copy link
Copy Markdown

codecov Bot commented May 23, 2026

Codecov Report

❌ Patch coverage is 67.47720% with 321 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.33%. Comparing base (f86013d) to head (0dc6c08).

Files with missing lines Patch % Lines
src/damacy_pop.c 52.21% 73 Missing and 24 partials ⚠️
src/damacy_lifecycle.c 78.54% 33 Missing and 20 partials ⚠️
src/planner/planner.c 53.16% 22 Missing and 15 partials ⚠️
src/damacy_plan.c 76.80% 19 Missing and 10 partials ⚠️
bench/main.c 0.00% 24 Missing ⚠️
src/prefetch/chunk_layout.c 72.41% 14 Missing and 10 partials ⚠️
src/damacy_push.c 63.04% 10 Missing and 7 partials ⚠️
src/damacy_scheduler.c 80.35% 5 Missing and 6 partials ⚠️
python/damacy/_api.c 0.00% 9 Missing ⚠️
src/prefetch/shard_index.c 38.46% 6 Missing and 2 partials ⚠️
... and 4 more

❌ Your patch check has failed because the patch coverage (67.47%) is below the target coverage (70.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@                  Coverage Diff                  @@
##           worktree-prefetch     #121      +/-   ##
=====================================================
- Coverage              58.33%   58.33%   -0.01%     
=====================================================
  Files                     56       58       +2     
  Lines                   7962     7881      -81     
  Branches                1397     1371      -26     
=====================================================
- Hits                    4645     4597      -48     
+ Misses                  2747     2724      -23     
+ Partials                 570      560      -10     
Flag Coverage Δ
unittests 58.33% <67.47%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
python/damacy/__init__.py 96.34% <100.00%> (+0.04%) ⬆️
src/damacy_config.c 65.51% <ø> (+2.29%) ⬆️
src/store/store.c 43.28% <0.00%> (ø)
src/platform/platform_io.posix.c 55.05% <60.00%> (+1.64%) ⬆️
src/store/store_fs.c 72.90% <72.72%> (-2.36%) ⬇️
src/prefetch/prefetcher.c 81.70% <90.90%> (+2.68%) ⬆️
src/prefetch/shard_index.c 48.41% <38.46%> (+0.54%) ⬆️
python/damacy/_api.c 0.00% <0.00%> (ø)
src/damacy_scheduler.c 80.35% <80.35%> (ø)
src/damacy_push.c 63.04% <63.04%> (ø)
... and 6 more

... and 9 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nclack nclack force-pushed the damacy-rewrite branch 4 times, most recently from 80fff84 to 3875ac9 Compare May 26, 2026 01:49
nclack added 3 commits May 26, 2026 16:50
## Summary

- Replace the planner's legacy synchronous zarr metadata/shard cache
reads with handles to the prefetch caches.
- Delete the old `zarr_meta_cache` / `zarr_shard_cache` path and route
planner inputs through `planner_sample`.
- Preserve sparse-zarr behavior: missing shard files become fill chunks,
while IO/decode/stat errors still fail the sample.
- Rename cache tuning/stats to match the new caches: `array_meta`,
`shard_index`, and `chunk_layout`.

## Notes

- `prefetch_handle` moved to a small standalone header so CUDA-facing
planner headers do not pull in `prefetch_cache.h`.
- Store-derived validation now happens asynchronously: missing URIs,
unsupported source dtypes, per-array rank mismatch, and decode failures
surface from `pop()`, not `push()`.
- Chunk-layout probing uses an actual ready shard touched by the sample
instead of assuming the origin shard exists.
- Non-blosc codecs legitimately return no chunk layout; unsupported
blosc codecs fail early during prefetch.

## Tests

- `cmake --build build --target damacy test_chunk_layout_cache
test_prefetcher test_planner`
- `env UV_CACHE_DIR=/tmp/uv-cache timeout 90s ctest --test-dir build -R
'test_(planner|chunk_layout_cache|prefetcher)$' --output-on-failure`
@nclack nclack changed the title damacy rewrite PR-1: file split + prefetcher producer damacy rewrite: prefetcher producer + planner handles May 30, 2026
@nclack nclack merged commit f9fea7e into worktree-prefetch May 30, 2026
6 checks passed
@nclack nclack deleted the damacy-rewrite branch May 30, 2026 00:21
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