/zarr-chunk-optimization:chunking-strategyfrom zarr-chunk-optimization
Benchmarks Zarr chunk shapes against actual read patterns, measuring wall-clock time and peak memory to guide rechunking decisions for multi-dimensional scientific arrays on cloud or local storage.
Ships in zarr-chunk-optimization. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Benchmarks candidate Zarr chunk shapes against the reads a dataset actually serves, measuring wall-clock time and peak memory before any rechunk.
Core principle: a read fetches and decompresses every chunk it touches, whole. Map reads want chunks short in time and wide in space, time-series reads the opposite, so measure candidates instead of guessing. Method: Nguyen et al. (2023), DOI: 10.1002/essoar.10511054.2.
When NOT to use:
Read pattern (dims time, lat, lon) | xarray (positional) | Script flag | Shape that favors it (float32) |
|---|---|---|---|
| Map at one time step | da.isel(time=t) | --slice-dims 0 | (1, 721, 1440), 4.2 MB |
| Time series at one point | da.isel(lat=i, lon=j) | --traverse-dims 0 | (1000, 32, 32), 4.1 MB |
Spectrum (dims time, freq, baseline) | da.isel(time=t, baseline=b) | --traverse-dims 1 | (8, 2048, 64), 4.2 MB |
mean ± std is run spread (ddof=0), not a confidence interval.scripts/benchmark_runner.py times reads of the store's existing layout. --configs is only a label copied into the output; it does not rechunk. Each candidate needs its own store (a sample rechunked with rechunking, or generated with synthetic-data) and its own run:
python scripts/benchmark_runner.py \
--dataset /scratch/era5_sample_c1000x32x32.zarr \
--configs "1000,32,32" \
--slice-dims 0 --traverse-dims 0 \
--runs 5 --output results_c1000x32x32.json
slice (--slice-dims d): fix the middle index along dim d, read the whole hyperplane.traverse (--traverse-dims d): fix every other dim at its middle, read the 1-D line along d.--runs must be at least 5. Only the first data variable is read.--warmup is parsed but not applied: one warm-up run always happens.error field and the script still exits 0; check before trusting the JSON (output format).slice or traverse plus a dim index.--runs 10 or more before comparing.assets/report-template.md or hand off to performance-reporting.| Mistake | Fix |
|---|---|
Passing several --configs against one store and reading the differences as chunk effects | Every run reads the same layout. One store per candidate |
--traverse-dims 1 2 on (time, lat, lon) to get time series | That reads lines along lat and lon. A time series is --traverse-dims 0 |
ds.sel(time=42) for "time step 42" | sel matches labels: KeyError on datetime coords. Use isel(time=42) |
sel(lat=slice(30, 60), lon=slice(-120, -60)) on ERA5-style grids | Latitude descends and longitude is 0–360, so both return empty. Use lat=slice(60, 30), lon=slice(240, 300) |
ds.chunk({...}).to_zarr(...) to build a candidate store | The source's encoding["chunks"] wins and the old layout is written. Delete encoding["chunks"] and encoding["preferred_chunks"] per variable first |
| Treating a Zarr v3 shard as the read unit | The inner chunk is the read unit; the shard is the storage object. Size and benchmark inner chunks for reads |
| Expecting Kerchunk or VirtualiZarr to provide a second layout | They reference existing chunks only. A new layout needs a rechunk |
| Reference | Load when |
|---|---|
| access-patterns.md | Mapping workflows to spatial, time-series and spectral reads |
| memory-constraints.md | Memory budgets, OOM, all-or-nothing chunk reads |
| benchmarking-methodology.md | Run counts, cache clearing, building candidate stores, pitfalls |
| cloud-storage-patterns.md | S3/GCS latency, request cost, sharding, caching |
| performance-interpretation.md | Reading results, PB, weighted scores, recommendations |
| nguyen-2023.md | Research basis for the method |
Read performance only (no write, rechunk or codec benchmarking), one variable per store.
assets/benchmark-config-example.json (opens in a new tab)assets/report-template.md (opens in a new tab)references/README.md (opens in a new tab)references/access-patterns.md (opens in a new tab)references/benchmarking-methodology.md (opens in a new tab)references/cloud-storage-patterns.md (opens in a new tab)references/memory-constraints.md (opens in a new tab)references/nguyen-2023.md (opens in a new tab)references/performance-interpretation.md (opens in a new tab)scripts/benchmark_runner.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Generated from the plugin's indexed repository (uw-ssec/savvy) — no native marketplace selected
npx claudepluginhub p/uw-ssec-zarr-chunk-optimization-plugins-zarr-chunk-optimization5 skills in this plugin
/access-pattern-analysisUse when choosing or benchmarking Zarr chunk shapes and the read workload is not yet written down; when a user describes their work informally ("I make maps", "I pull time series at stations", "I look at spectra"); when several teams or workflows share one dataset and need relative weights; or when reads are slow and the chunk layout may not match how the data is read./performance-reportingUse when Zarr chunking benchmark results already exist, as benchmark_runner.py JSON or as read times per chunk shape, and someone needs them compared, ranked, turned into a chunk-shape recommendation, charted, or written up as a report for stakeholders. Also use when asked for a performance bias score, a memory-budget check, or a weighted score for a mixed map and time-series workload./rechunkingUse when an existing Zarr (.zarr) array or dataset must be rechunked to a new layout, such as changing chunk sizes or shard shape, optimizing Zarr storage layout, or applying a chunk configuration identified by benchmarking, on local disk, S3, or GCS. Also use when rechunker, dask rechunk, or xarray to_zarr runs out of memory or raises chunk alignment errors during a rechunk./synthetic-dataUse when a Zarr chunking benchmark needs input data and the production dataset is unavailable, restricted, or too large to copy; when the user asks for a synthetic, random, or test Zarr dataset or array with a given shape, chunks, dtype, or compression; or when a smaller benchmark sample must be cut from an existing Zarr store, on local disk or S3.Other plugins' skills for the same job