Skip to content

Conversation

@d-v-b
Copy link
Contributor

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

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
Copy link

codspeed-hq bot commented Feb 12, 2026

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
Member

Really cool!

@d-v-b d-v-b merged commit 3e7d24d into zarr-developers:main Feb 12, 2026
26 checks passed
@d-v-b d-v-b deleted the perf/improve-morton-ordering branch February 12, 2026 21:08
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