Skip to content

Commit 32c7ab9

Browse files
mkitticlauded-v-b
authored
Add non-power-of-2 shapes for Morton coding to benchmarks (#3717)
* tests: Add non-power-of-2 shard shapes to benchmarks Add (30,30,30) to large_morton_shards and (10,10,10), (20,20,20), (30,30,30) to morton_iter_shapes to benchmark the scalar fallback path for non-power-of-2 shapes, which are not fully covered by the vectorized hypercube path. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * tests: Add near-miss power-of-2 shape (33,33,33) to benchmarks Documents the performance penalty when a shard shape is just above a power-of-2 boundary, causing n_z to jump from 32,768 to 262,144. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * style: Apply ruff format to benchmark file Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * changes: Add changelog entry for PR #3717 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: Davis Bennett <davis.v.bennett@gmail.com>
1 parent efed3a4 commit 32c7ab9

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

changes/3717.misc.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add benchmarks for Morton order computation with non-power-of-2 and near-miss shard shapes, covering both pure computation and end-to-end read/write performance.

tests/benchmarks/test_indexing.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ def read_with_cache_clear() -> None:
106106

107107
# Benchmark with larger chunks_per_shard to make Morton order impact more visible
108108
large_morton_shards = (
109-
(32,) * 3, # With 1x1x1 chunks: 32x32x32 = 32768 chunks per shard
109+
(32,) * 3, # With 1x1x1 chunks: 32x32x32 = 32768 chunks per shard (power-of-2)
110+
(30,) * 3, # With 1x1x1 chunks: 30x30x30 = 27000 chunks per shard (non-power-of-2)
111+
(33,)
112+
* 3, # With 1x1x1 chunks: 33x33x33 = 35937 chunks per shard (near-miss: just above power-of-2)
110113
)
111114

112115

@@ -197,9 +200,13 @@ def read_with_cache_clear() -> None:
197200

198201
# Benchmark for morton_order_iter directly (no I/O)
199202
morton_iter_shapes = (
200-
(8, 8, 8), # 512 elements
201-
(16, 16, 16), # 4096 elements
202-
(32, 32, 32), # 32768 elements
203+
(8, 8, 8), # 512 elements (power-of-2)
204+
(10, 10, 10), # 1000 elements (non-power-of-2)
205+
(16, 16, 16), # 4096 elements (power-of-2)
206+
(20, 20, 20), # 8000 elements (non-power-of-2)
207+
(32, 32, 32), # 32768 elements (power-of-2)
208+
(30, 30, 30), # 27000 elements (non-power-of-2)
209+
(33, 33, 33), # 35937 elements (near-miss: just above power-of-2, n_z=262144)
203210
)
204211

205212

0 commit comments

Comments
 (0)