Skip to content

Commit b30ae18

Browse files
aldenksd-v-b
andauthored
Add benchmarks for sharded + local store indexing (#3663)
* 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. * use latencystore with 10ms get latency instead of localstore * use .01s of latency * set get latency to .0001s --------- Co-authored-by: Davis Bennett <davis.v.bennett@gmail.com>
1 parent 3fa19d2 commit b30ae18

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

tests/benchmarks/test_indexing.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,27 @@
2222
(slice(None), slice(0, 3, 2), slice(0, 10)),
2323
)
2424

25+
shards = (
26+
None,
27+
(50,) * 3,
28+
)
29+
2530

26-
@pytest.mark.parametrize("store", ["memory"], indirect=["store"])
31+
@pytest.mark.parametrize("store", ["memory", "memory_get_latency"], indirect=["store"])
2732
@pytest.mark.parametrize("indexer", indexers, ids=str)
33+
@pytest.mark.parametrize("shards", shards, ids=str)
2834
def test_slice_indexing(
29-
store: Store, indexer: tuple[int | slice], benchmark: BenchmarkFixture
35+
store: Store,
36+
indexer: tuple[int | slice],
37+
shards: tuple[int, ...] | None,
38+
benchmark: BenchmarkFixture,
3039
) -> None:
3140
data = create_array(
3241
store=store,
3342
shape=(105,) * 3,
3443
dtype="uint8",
3544
chunks=(10,) * 3,
36-
shards=None,
45+
shards=shards,
3746
compressors=None,
3847
filters=None,
3948
fill_value=0,

tests/conftest.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
from zarr.core.metadata.v3 import ArrayV3Metadata
4141
from zarr.core.sync import sync
4242
from zarr.storage import FsspecStore, LocalStore, MemoryStore, StorePath, ZipStore
43+
from zarr.testing.store import LatencyStore
4344

4445
if TYPE_CHECKING:
4546
from collections.abc import Generator
@@ -58,8 +59,8 @@
5859

5960

6061
async def parse_store(
61-
store: Literal["local", "memory", "fsspec", "zip"], path: str
62-
) -> LocalStore | MemoryStore | FsspecStore | ZipStore:
62+
store: Literal["local", "memory", "fsspec", "zip", "memory_get_latency"], path: str
63+
) -> LocalStore | MemoryStore | FsspecStore | ZipStore | LatencyStore:
6364
if store == "local":
6465
return await LocalStore.open(path)
6566
if store == "memory":
@@ -68,6 +69,8 @@ async def parse_store(
6869
return await FsspecStore.open(url=path)
6970
if store == "zip":
7071
return await ZipStore.open(path + "/zarr.zip", mode="w")
72+
if store == "memory_get_latency":
73+
return LatencyStore(MemoryStore(), get_latency=0.0001, set_latency=0)
7174
raise AssertionError
7275

7376

0 commit comments

Comments
 (0)