Skip to content

perf:improve performance of morton order iter#3705

Merged
d-v-b merged 3 commits into
zarr-developers:mainfrom
d-v-b:perf/improve-morton-ordering
Feb 12, 2026
Merged

perf:improve performance of morton order iter#3705
d-v-b merged 3 commits into
zarr-developers:mainfrom
d-v-b:perf/improve-morton-ordering

Conversation

@d-v-b

@d-v-b d-v-b commented Feb 12, 2026

Copy link
Copy Markdown
Contributor

Our morton_order_iter function uses nested O(N) loops and doesn't cache its results. These make it slow. This PR fixes both of these, so it should be faster.

@github-actions github-actions Bot added the needs release notes Automatically applied to PRs which haven't added release notes label Feb 12, 2026
@d-v-b d-v-b added benchmark Code will be benchmarked in a CI job. and removed needs release notes Automatically applied to PRs which haven't added release notes labels Feb 12, 2026
@d-v-b d-v-b changed the title improve performance of morton order iter perf:improve performance of morton order iter Feb 12, 2026
@d-v-b
d-v-b requested a review from a team February 12, 2026 19:22
@codspeed-hq

codspeed-hq Bot commented Feb 12, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by ×2.1

⚡ 4 improved benchmarks
✅ 44 untouched benchmarks
⏩ 6 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
WallTime test_write_array[memory-Layout(shape=(1000000,), chunks=(100,), shards=(1000000,))-gzip] 15.5 s 9.6 s +61.75%
WallTime test_write_array[memory-Layout(shape=(1000000,), chunks=(100,), shards=(1000000,))-None] 11.4 s 5.4 s ×2.1
WallTime test_write_array[local-Layout(shape=(1000000,), chunks=(100,), shards=(1000000,))-None] 11.4 s 5.5 s ×2.1
WallTime test_write_array[local-Layout(shape=(1000000,), chunks=(100,), shards=(1000000,))-gzip] 16 s 9.6 s +66.84%

Comparing d-v-b:perf/improve-morton-ordering (05e16ca) with main (1ed266d)

Open in CodSpeed

Footnotes

  1. 6 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@normanrz

Copy link
Copy Markdown
Member

Really cool!

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

Labels

benchmark Code will be benchmarked in a CI job.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants