Skip to content

perf(indexing): speed up sorted 1-D coordinate selections#4172

Open
selmanozleyen wants to merge 7 commits into
zarr-developers:mainfrom
selmanozleyen:perf/coordinate-indexer-1d-fastpath
Open

perf(indexing): speed up sorted 1-D coordinate selections#4172
selmanozleyen wants to merge 7 commits into
zarr-developers:mainfrom
selmanozleyen:perf/coordinate-indexer-1d-fastpath

Conversation

@selmanozleyen

@selmanozleyen selmanozleyen commented Jul 21, 2026

Copy link
Copy Markdown

Summary

Speeds up CoordinateIndexer for sorted, in-bounds, one-dimensional integer selections on regular chunk grids.

Because the coordinates are already grouped by chunk, this uses searchsorted over the touched chunk boundaries instead of repeatedly processing the full selection.

Runs Elements main This PR
1,024 1.48M 8.7 ms 0.5 ms
4,096 5.94M 35 ms 2.1 ms
8,192 11.9M 71 ms 4.5 ms

Closes #4170

Author attestation

  • I am a human, these are my changes, and I have reviewed and understood every change and can explain why each is correct.

TODO

  • Add unit tests and/or doctests in docstrings
  • Add docstrings and API docs — not applicable; no public API changes
  • Update the user guide — not applicable; behavior is unchanged
  • Changes documented in changes/
  • GitHub Actions have all passed
  • Test coverage is 100% (Codecov passes)

@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.85%. Comparing base (80e00ae) to head (4b43d92).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4172      +/-   ##
==========================================
+ Coverage   93.84%   93.85%   +0.01%     
==========================================
  Files          91       91              
  Lines       12549    12573      +24     
==========================================
+ Hits        11777    11801      +24     
  Misses        772      772              
Files with missing lines Coverage Δ
src/zarr/core/indexing.py 96.40% <100.00%> (+0.10%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/zarr/core/indexing.py Outdated
Comment thread changes/4170.misc.md
@selmanozleyen
selmanozleyen requested a review from d-v-b July 22, 2026 22:01
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.

arr_1d[np.sort(idx)] can be much faster (CoordinateIndexer fast path)

2 participants