Repository navigation
Conversation
- Chunk output variables as [B, n_times] instead of [1, n_times], with B sized for ~8 MB per chunk (max 1024, and at most one worker's share). run_parent rounds each worker's block up to a multiple of B, so every chunk belongs to one worker and concurrent writes stay lock-free. - ZarrStore opens the store and arrays once, and buffers locations on a background thread, writing one store_chunk per variable per chunk. Short series and missing variables are padded with NaN. - Write all ids in one call into a single chunk. - zstd-compress the variable and id arrays. - Add a test with several concurrent workers, a location count that is a multiple of neither B nor the worker count, a short series and a missing variable, and check the chunk file count. Closes #12 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014HpTYAu1UyHLpFHz3ZVHcd
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.
Closes #12.
What changed
[B, n_times]instead of[1, n_times].zarr::chunk_locations(total_steps, per_worker)sizesBfor about 8 MB of f32 per chunk, capped at 1024 and at one worker's share of the locations.run_parentrounds each worker'schunk_sizeup to a multiple ofB, so every chunk belongs to exactly one worker and concurrent writes stay lock-free.ZarrStoreopens the store and every array once. It then buffers locations on a writer thread, like the other writers, and writes onestore_chunkper variable per chunk. Short series and missing variables are padded with NaN, and so are the rows past the end of the last partial chunk. If a block doesn't line up with a chunk (a caller-chosenstart_idx), it falls back tostore_array_subset.idarrays.variablesattribute that lists the output arrays, so workers can open them all up front.create_zarr_storetakes a newchunk_locationsargument, andZarrStore::newnow returnsBmiResult.Files
For 7 locations with
B = 3, each variable now has 3 chunk files (c/0/0,c/1/0,c/2/0) instead of 7. In general it'sceil(n_locations / B)per variable.Testing
cargo test: all tests pass, includingtest_all_formats_equivalent.test_zarr_multi_worker_partial_chunks: 23 locations, 4 workers andB = 5, so 3 aligned workers write concurrently from threads, and the last chunk is partial. One location has a short series and another is missing a variable. The test checks the values, the NaN fill, and that each variable hasceil(23/5) = 5chunk files.xr.open_zarr, zarr-python 3.1) with correct values andZstdCodec(level=3).--no-default-features, and with onlyzarr. No new clippy warnings.Note
This touches the Zarr block of
run_parent, which the NetCDF rework (theclaude/eager-goodall-eudoaobranch) also edits, so whichever merges second may have a small conflict there.🤖 Generated with Claude Code
https://claude.ai/code/session_014HpTYAu1UyHLpFHz3ZVHcd
Generated by Claude Code