Skip to content

B6b: Block sizing and Zarr v3 shards #97

Closed

Description

@Claptar

Part of #87.

wave 3 · 0.17.6 · size L · starts after: B4 (#94) and B5 (#95) (same files), B6a (#96) (the harness)

Goal. Reads and writes line up with the source's chunks and shards, so anndata 0.13's default Zarr v3 stores stream at the cost --chunk implies.

Owns: core/subset.py (block I/O), storage/__init__.py (copy_dataset, create_dataset)

Approach:

  • Sparse subset uses --chunk-sized blocks, not a fixed 4096 rows (F032).
  • Align row blocks to the chunk height (F061), and to the shard on write (F031, F036; verify F036 first, it is unverified). Keep the shard and its inner chunks on output (F033).
  • Cache shard indexes across block reads (F062).
  • Split gets at least one chunk height per output block (F060). Lower HDF5's per-file cache for many open outputs (F079).
  • copy_dataset blocks by rows, not by whole source-chunk heights (F081).

Findings

Ref Sev Finding Where
F031 H Dense subset/split of an anndata 0.13 Zarr v3 store (sharded by default) rewrites a whole shard for every --chunk block: about 250x slower, … src/adata/core/subset.py:441
F032 H Sparse subset/split blocks are a fixed 4096 major rows that --chunk cannot change; for CSC the block grows with n_obs src/adata/core/subset.py:626
F033 H Inputs in anndata's default Zarr v3 layout (auto-sharded, inner chunks of about 1 KB) give outputs that drop the shard and keep the … src/adata/core/subset.py:713
F036 H Outputs that keep a source's Zarr shard are written in blocks far smaller than the shard, so zarr re-encodes the whole shard on every … (unverified) src/adata/storage/__init__.py:335
F060 M split and subset outputs inherit the source's chunk height but get only --chunk/G rows per block, so every output chunk is decompressed and … src/adata/core/subset.py:444
F061 M Row blocks of --chunk rows are not aligned to the source's chunk height, so tall-chunked or default-chunked narrow dense X is decompressed … src/adata/core/subset.py:459
F062 M Zarr v3 sharded inputs re-fetch the shard index on every block read: subset and concat of an anndata-default store are 50 to 95x slower … src/adata/core/subset.py:631
F079 M split holds up to 1,024 HDF5 outputs open at once, about 0.9 MB of HDF5 cache each, so RSS reaches about 1 GB with group count, not --chunk src/adata/core/subset.py:1176
F081 M copy_dataset reads a whole source-chunk height across the full width, so memory scales with the input (the whole matrix for column-chunked … src/adata/storage/__init__.py:700

Done when one PR on fix/b6b closes this, with a regression test against an oracle for every finding, and docs and changelog in the same PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions