Skip to content

perf(data): direct chunk reads with zarr-python 3 - #199

Open
janickm wants to merge 1 commit into
stack/zarr3/05-zarr-format-v3from
stack/zarr3/06-direct-reads
Open

janickm wants to merge 1 commit into
stack/zarr3/05-zarr-format-v3from
stack/zarr3/06-direct-reads

Conversation

@janickm

@janickm janickm commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

zarr-python 3's codec pipeline decodes each chunk into a temporary buffer and copies it into the output array (zarr-python#2904), and its per-read overhead dominates reads of small frame arrays (~550 us per frame read vs ~200 us with zarr-python 2).

Basic selections (integers, unit-step slices, Ellipsis) of arrays of indexed tar archives opened for reading are now read directly: chunks are determined by zarr-python's indexer, read from the archive and blosc-decompressed into the output array (in place for complete chunks). Uncompressed single-chunk arrays (e.g., encoded images) are read-only views of their chunk record (no decoding, no copies). Large chunks of a read (>= 2 MiB) are decoded concurrently on a thread pool, bounded to two concurrent reads per process. Supported are regular chunk grids, C order, numeric / boolean data of native byte order and fixed-length bytes, without filters, uncompressed or blosc compressed (all arrays written by ncore), all other arrays and selections are read via zarr-python.

Read plans are derived per read (sub-microsecond, nothing is cached), results are read-only (as all read results), missing chunks read as the fill value, and the parallel reads state is re-created in forked processes.

NCORE_ZARR3_DIRECT_READS=0 reads all arrays via zarr-python.

Frame reads of the test sequence take ~240 us instead of ~550 us.

@copy-pr-bot

copy-pr-bot Bot commented Oct 14, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@janickm
janickm added this pull request to stack #201 October 14, 2026 07:28
@janickm

janickm commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator Author

/ok to test 34e1743

@janickm

janickm commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator Author

/ok to test 023cc64

@janickm
janickm force-pushed the stack/zarr3/06-direct-reads branch from 023cc64 to b38bb88 Compare October 14, 2026 10:02
@janickm

janickm commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator Author

/ok to test b38bb88

@janickm
janickm force-pushed the stack/zarr3/06-direct-reads branch from b38bb88 to f052a83 Compare October 14, 2026 10:09
@janickm

janickm commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator Author

/ok to test f052a83

@janickm
janickm force-pushed the stack/zarr3/06-direct-reads branch from f052a83 to 2d3c0ed Compare October 14, 2026 11:58
@janickm

janickm commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator Author

/ok to test 2d3c0ed

@janickm
janickm force-pushed the stack/zarr3/06-direct-reads branch from 2d3c0ed to ee42290 Compare October 14, 2026 14:16
@janickm

janickm commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator Author

/ok to test ee42290

@janickm
janickm force-pushed the stack/zarr3/06-direct-reads branch from ee42290 to 1f00b76 Compare October 14, 2026 14:43
@janickm

janickm commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator Author

/ok to test 1f00b76

@janickm
janickm force-pushed the stack/zarr3/06-direct-reads branch from 1f00b76 to 2008352 Compare October 14, 2026 15:32
@janickm

janickm commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator Author

/ok to test 2008352

@janickm
janickm force-pushed the stack/zarr3/06-direct-reads branch from 2008352 to 4a70f2e Compare October 15, 2026 07:55
@janickm

janickm commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator Author

/ok to test 4a70f2e

@janickm

janickm commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator Author

/ok to test c17b77c

@janickm
janickm force-pushed the stack/zarr3/06-direct-reads branch from c17b77c to b10bd34 Compare October 19, 2026 11:52
@janickm

janickm commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator Author

/ok to test b10bd34

@janickm
janickm force-pushed the stack/zarr3/06-direct-reads branch from b10bd34 to e63f3c8 Compare October 19, 2026 11:58
@janickm

janickm commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator Author

/ok to test e63f3c8

@janickm
janickm force-pushed the stack/zarr3/06-direct-reads branch from e63f3c8 to d817878 Compare October 19, 2026 13:56
@janickm

janickm commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator Author

/ok to test d817878

Comment thread ncore/impl/data/backend_zarr3.py Outdated
Comment thread ncore/impl/data/backend_zarr3.py Outdated
@janickm
janickm force-pushed the stack/zarr3/06-direct-reads branch from d817878 to 56bc675 Compare October 20, 2026 09:27
@janickm

janickm commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator Author

/ok to test 56bc675

Comment thread ncore/impl/data/backend_zarr3.py
Comment thread ncore/impl/data/backend_zarr3.py
Comment thread ncore/impl/data/backend_zarr3.py
Comment thread ncore/impl/data/backend_zarr3.py
Comment thread ncore/impl/data/backend_zarr3.py
Comment thread ncore/impl/data/backend_zarr3.py
@janickm
janickm force-pushed the stack/zarr3/06-direct-reads branch from 56bc675 to 3574994 Compare October 20, 2026 10:19
@janickm

janickm commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator Author

/ok to test 3574994

@janickm
janickm marked this pull request as ready for review October 20, 2026 11:42
@janickm
janickm force-pushed the stack/zarr3/06-direct-reads branch from 3574994 to 1277ca0 Compare October 21, 2026 08:37
@janickm

janickm commented Oct 21, 2026

Copy link
Copy Markdown
Collaborator Author

/ok to test 1277ca0

@janickm
janickm force-pushed the stack/zarr3/06-direct-reads branch from 1277ca0 to 7d0965e Compare October 21, 2026 08:53
@janickm

janickm commented Oct 21, 2026

Copy link
Copy Markdown
Collaborator Author

/ok to test 7d0965e

zarr-python 3's codec pipeline decodes each chunk into a temporary
buffer and copies it into the output array (zarr-python#2904), and its
per-read overhead dominates reads of small frame arrays (~550 us per
frame read vs ~200 us with zarr-python 2).

Basic selections (integers, unit-step slices, Ellipsis) of arrays of
stores opened for reading are now read directly: zarr-python's indexer
determines the chunks of a read, which are read from the store and
blosc-decompressed into the output array (in place for complete chunks
that are contiguous blocks of the output array). Records of indexed tar
archives are read directly from the archive (positional reads), records
of other zarr-python stores (e.g., directories) via the store.

- Uncompressed single-chunk arrays (e.g., encoded images) are read-only
  views of their chunk record (no decoding, no copies)
- Large chunks of a read (>= 2 MiB) are decoded concurrently on a
  thread pool (at most 8 threads), bounded to two concurrent reads per
  process
- Supported are all arrays written by ncore: regular chunk grids, C
  order, numeric / boolean data of native byte order and fixed-length
  bytes, uncompressed or blosc compressed, without filters. All other
  arrays (e.g., other codecs, written by other zarr writers) and
  selections are read via zarr-python

Read plans are derived per read (sub-microsecond, nothing is cached),
results are read-only (as all read results), missing chunks read as the
fill value, and the parallel reads state is re-created in forked
processes. NCORE_ZARR3_DIRECT_READS=0 reads all arrays via zarr-python.

Frame reads of the test sequence take ~240 us instead of ~550 us.
Multi-chunk arrays (e.g., point clouds chunked along points) read 1.4x
to 3.7x faster, and up to ~17x for multiple large chunks (concurrent,
in-place decompression).
@janickm
janickm force-pushed the stack/zarr3/06-direct-reads branch from 7d0965e to 52d7e8e Compare October 21, 2026 09:11

This branch has not been deployed

No deployments
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