@@ -1516,3 +1516,36 @@ def test_group_members_performance(store: MemoryStore) -> None:
15161516 elapsed = time .time () - start
15171517
15181518 assert elapsed < (1.1 * get_latency ) + 0.001
1519+
1520+
1521+ @pytest .mark .parametrize ("store" , ["memory" ], indirect = True )
1522+ def test_group_members_concurrency_limit (store : MemoryStore ) -> None :
1523+ """
1524+ Test that the performance of Group.members is robust to asynchronous latency
1525+ """
1526+ get_latency = 0.02
1527+
1528+ # use the input store to create some groups
1529+ group_create = zarr .group (store = store )
1530+ num_groups = 10
1531+
1532+ # Create some groups
1533+ for i in range (num_groups ):
1534+ group_create .create_group (f"group{ i } " )
1535+
1536+ latency_store = LatencyStore (store , get_latency = get_latency )
1537+ # create a group with some latency on get operations
1538+ group_read = zarr .group (store = latency_store )
1539+
1540+ # check how long it takes to iterate over the groups
1541+ # if .members is sensitive to IO latency,
1542+ # this should take (num_groups * get_latency) seconds
1543+ # otherwise, it should take only marginally more than get_latency seconds
1544+ from zarr .core .config import config
1545+
1546+ with config .set ({"async.concurrency" : 1 }):
1547+ start = time .time ()
1548+ _ = group_read .members ()
1549+ elapsed = time .time () - start
1550+
1551+ assert elapsed > num_groups * get_latency
0 commit comments