chunking-strategy
Use when choosing or tuning Zarr chunk shapes for a multi-dimensional scientific array on S3, GCS or local disk, when map reads or time-series reads from a…
от uw-ssec★ 33 звезды на GitHub
Установить chunking-strategy в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Chunking Strategy Benchmarking
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 to Use
- Picking chunks for a new store, or a target layout before rechunking.
- Maps load fast but time series crawl (or the reverse), small selections run out of memory, or reads issue thousands of tiny GETs.
When NOT to use:
- Read patterns are still unknown or unweighted: use access-pattern-analysis first.
- The shape is decided and the data must be rewritten: use rechunking.
- No representative data to benchmark: use synthetic-data to generate stores.
- Results exist and need a stakeholder report: use performance-reporting.
Quick Reference
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 |
- Size: aim for compressed chunk objects of 1–100 MB on object storage. KB-sized chunks are latency-bound (each GET pays ~20–100 ms).
- Memory per read: up to uncompressed chunk bytes × chunks the selection touches, plus 1.5–2× overhead.
- PB (Nguyen et al.) = max / min of mean wall time across patterns for one config. Plugin heuristic bands: < 1.5 balanced, 1.5–3 moderate, 3–10 biased, > 10 extreme.
- Weighted score = Σ wᵢ × Tᵢ over patterns (weights from access-pattern-analysis); rank by it. Keep PB unweighted.
mean ± stdis run spread (ddof=0), not a confidence interval.
Running the Benchmark
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.- Both default to every dim.
--runsmust be at least 5. Only the first data variable is read. --warmupis parsed but not applied: one warm-up run always happens.- A failed benchmark is an entry with only an
errorfield and the script still exits 0; check before trusting the JSON (output format). - On a local store every timed run follows a warm-up read of the same selection, so the OS page cache is warm: results show decode cost, not disk I/O. Benchmark on the production object store when I/O is the question.
Workflow
- Map each weighted read pattern to
sliceortraverseplus a dim index. - Pick 3–5 candidates (current layout, one per dominant pattern, one balanced), varying one dim at a time. Drop any over the memory budget.
- Build one store per candidate on a sample where every pattern touches 10+ chunks.
- Benchmark each store. If std/mean > 0.3, rerun with
--runs 10or more before comparing. - Compute PB and weighted score; fill
assets/report-template.mdor hand off to performance-reporting.
Common Mistakes
| 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 VirtualiZar |
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- assets/benchmark-config-example.json
- assets/report-template.md
- references/README.md
- references/access-patterns.md
- references/benchmarking-methodology.md
- references/cloud-storage-patterns.md
- references/memory-constraints.md
- references/nguyen-2023.md
- references/performance-interpretation.md
- scripts/benchmark_runner.py
FAQ
Что делает скилл chunking-strategy?
Use when choosing or tuning Zarr chunk shapes for a multi-dimensional scientific array on S3, GCS or local disk, when map reads or time-series reads from a Zarr store are slow or run out of memory, or when comparing candidate chunk configurations by wall-clock time, peak memory or performance bias (Nguyen et al. 2023) before rechunking.
Как установить скилл chunking-strategy?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл chunking-strategy запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
theme-factory
AnthropicToolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
access
AnthropicManage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
configure
AnthropicSet up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
access
AnthropicManage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…