From c15bd6051c656d5c0ad3e9bd3150928f1d900017 Mon Sep 17 00:00:00 2001 From: Alden Keefe Sampson Date: Mon, 19 Jan 2026 22:54:17 -0500 Subject: [PATCH 1/4] Add benchmarks for sharded + local store indexing Parameterize with shards and no shards. Parameterize with local + memory store to have an example of a store which has some modest latency. --- tests/benchmarks/test_indexing.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/benchmarks/test_indexing.py b/tests/benchmarks/test_indexing.py index 1ad4f4b575..120eca9517 100644 --- a/tests/benchmarks/test_indexing.py +++ b/tests/benchmarks/test_indexing.py @@ -22,18 +22,27 @@ (slice(None), slice(0, 3, 2), slice(0, 10)), ) +shards = ( + None, + (50,) * 3, +) + -@pytest.mark.parametrize("store", ["memory"], indirect=["store"]) +@pytest.mark.parametrize("store", ["memory", "local"], indirect=["store"]) @pytest.mark.parametrize("indexer", indexers, ids=str) +@pytest.mark.parametrize("shards", shards, ids=str) def test_slice_indexing( - store: Store, indexer: tuple[int | slice], benchmark: BenchmarkFixture + store: Store, + indexer: tuple[int | slice], + shards: tuple[int, ...] | None, + benchmark: BenchmarkFixture, ) -> None: data = create_array( store=store, shape=(105,) * 3, dtype="uint8", chunks=(10,) * 3, - shards=None, + shards=shards, compressors=None, filters=None, fill_value=0, From 11e0f5b4b09cb9ff60bb933915caf6d0745b463e Mon Sep 17 00:00:00 2001 From: Davis Vann Bennett Date: Sun, 25 Jan 2026 16:42:09 +0100 Subject: [PATCH 2/4] use latencystore with 10ms get latency instead of localstore --- tests/benchmarks/test_indexing.py | 2 +- tests/conftest.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/benchmarks/test_indexing.py b/tests/benchmarks/test_indexing.py index 120eca9517..9ca0d8e1af 100644 --- a/tests/benchmarks/test_indexing.py +++ b/tests/benchmarks/test_indexing.py @@ -28,7 +28,7 @@ ) -@pytest.mark.parametrize("store", ["memory", "local"], indirect=["store"]) +@pytest.mark.parametrize("store", ["memory", "memory_get_latency"], indirect=["store"]) @pytest.mark.parametrize("indexer", indexers, ids=str) @pytest.mark.parametrize("shards", shards, ids=str) def test_slice_indexing( diff --git a/tests/conftest.py b/tests/conftest.py index 63c8950cff..460537f7f7 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -40,6 +40,7 @@ from zarr.core.metadata.v3 import ArrayV3Metadata from zarr.core.sync import sync from zarr.storage import FsspecStore, LocalStore, MemoryStore, StorePath, ZipStore +from zarr.testing.store import LatencyStore if TYPE_CHECKING: from collections.abc import Generator @@ -58,8 +59,8 @@ async def parse_store( - store: Literal["local", "memory", "fsspec", "zip"], path: str -) -> LocalStore | MemoryStore | FsspecStore | ZipStore: + store: Literal["local", "memory", "fsspec", "zip", "memory_get_latency"], path: str +) -> LocalStore | MemoryStore | FsspecStore | ZipStore | LatencyStore: if store == "local": return await LocalStore.open(path) if store == "memory": @@ -68,6 +69,8 @@ async def parse_store( return await FsspecStore.open(url=path) if store == "zip": return await ZipStore.open(path + "/zarr.zip", mode="w") + if store == "memory_get_latency": + return LatencyStore(MemoryStore(), get_latency=10, set_latency=0) raise AssertionError From 520f9156c0be31a4fe1605f0f766aa0a64eb016a Mon Sep 17 00:00:00 2001 From: Davis Vann Bennett Date: Sun, 25 Jan 2026 17:01:15 +0100 Subject: [PATCH 3/4] use .01s of latency --- tests/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index 460537f7f7..fe39b7c5df 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -70,7 +70,7 @@ async def parse_store( if store == "zip": return await ZipStore.open(path + "/zarr.zip", mode="w") if store == "memory_get_latency": - return LatencyStore(MemoryStore(), get_latency=10, set_latency=0) + return LatencyStore(MemoryStore(), get_latency=0.01, set_latency=0) raise AssertionError From 627105046f2ebcf16ff29052884f546c0be5145e Mon Sep 17 00:00:00 2001 From: Davis Vann Bennett Date: Sun, 25 Jan 2026 17:19:38 +0100 Subject: [PATCH 4/4] set get latency to .0001s --- tests/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index fe39b7c5df..23a1e87d0a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -70,7 +70,7 @@ async def parse_store( if store == "zip": return await ZipStore.open(path + "/zarr.zip", mode="w") if store == "memory_get_latency": - return LatencyStore(MemoryStore(), get_latency=0.01, set_latency=0) + return LatencyStore(MemoryStore(), get_latency=0.0001, set_latency=0) raise AssertionError