Skip to content

Commit 2a68c53

Browse files
committed
feat: Add reads_regional microbenchmark comparing JSON, gRPC DP, and gRPC CP
1 parent b8f8828 commit 2a68c53

4 files changed

Lines changed: 405 additions & 0 deletions

File tree

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Copyright 2026 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
import itertools
15+
import os
16+
from typing import Dict, List
17+
18+
import yaml
19+
20+
try:
21+
from tests.perf.microbenchmarks.time_based.reads_regional.parameters import (
22+
TimeBasedReadParameters,
23+
)
24+
except ModuleNotFoundError:
25+
from reads_regional.parameters import TimeBasedReadParameters
26+
27+
28+
def _get_params() -> Dict[str, List[TimeBasedReadParameters]]:
29+
"""Generates a dictionary of benchmark parameters for time based read operations."""
30+
params: Dict[str, List[TimeBasedReadParameters]] = {}
31+
config_path = os.path.join(os.path.dirname(__file__), "config.yaml")
32+
with open(config_path, "r") as f:
33+
config = yaml.safe_load(f)
34+
35+
common_params = config["common"]
36+
read_types = common_params["read_types"]
37+
file_sizes_mib = common_params["file_sizes_mib"]
38+
chunk_sizes_kib = common_params["chunk_sizes_kib"]
39+
num_ranges = common_params["num_ranges"]
40+
rounds = common_params["rounds"]
41+
duration = common_params["duration"]
42+
warmup_duration = common_params["warmup_duration"]
43+
44+
# All read types use the same regional bucket
45+
bucket_name = os.environ.get(
46+
"DEFAULT_STANDARD_BUCKET", config["defaults"]["DEFAULT_STANDARD_BUCKET"]
47+
)
48+
49+
for workload in config["workload"]:
50+
workload_name = workload["name"]
51+
params[workload_name] = []
52+
pattern = workload["pattern"]
53+
processes = workload["processes"]
54+
coros = workload["coros"]
55+
56+
# Create a product of all parameter combinations
57+
product = itertools.product(
58+
read_types,
59+
file_sizes_mib,
60+
chunk_sizes_kib,
61+
num_ranges,
62+
processes,
63+
coros,
64+
)
65+
66+
for (
67+
read_type,
68+
file_size_mib,
69+
chunk_size_kib,
70+
num_ranges_val,
71+
num_processes,
72+
num_coros,
73+
) in product:
74+
file_size_bytes = file_size_mib * 1024 * 1024
75+
chunk_size_bytes = chunk_size_kib * 1024
76+
77+
num_files = num_processes
78+
79+
# Create a descriptive name for the parameter set
80+
name = f"{pattern}_{read_type}_{num_processes}p_{num_coros}c_{file_size_mib}MiB_{chunk_size_kib}KiB_{num_ranges_val}ranges"
81+
82+
params[workload_name].append(
83+
TimeBasedReadParameters(
84+
name=name,
85+
workload_name=workload_name,
86+
pattern=pattern,
87+
bucket_name=bucket_name,
88+
bucket_type="regional",
89+
read_type=read_type,
90+
num_coros=num_coros,
91+
num_processes=num_processes,
92+
num_files=num_files,
93+
rounds=rounds,
94+
chunk_size_bytes=chunk_size_bytes,
95+
file_size_bytes=file_size_bytes,
96+
duration=duration,
97+
warmup_duration=warmup_duration,
98+
num_ranges=num_ranges_val,
99+
)
100+
)
101+
return params
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
common:
2+
read_types:
3+
- "async_json"
4+
- "async_grpc_dp"
5+
- "async_grpc_cp"
6+
file_sizes_mib:
7+
- 10240 # 10GiB
8+
chunk_sizes_kib: [64]
9+
num_ranges: [1]
10+
rounds: 1
11+
duration: 30 # seconds
12+
warmup_duration: 5 # seconds
13+
14+
workload:
15+
############# multi process multi coroutine #########
16+
- name: "read_seq_multi_process"
17+
pattern: "seq"
18+
coros: [1]
19+
processes: [96]
20+
21+
- name: "read_rand_multi_process"
22+
pattern: "rand"
23+
coros: [1, 16]
24+
processes: [1]
25+
26+
defaults:
27+
DEFAULT_STANDARD_BUCKET: "chandrasiri-benchmarks-rb"
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright 2026 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
from dataclasses import dataclass
15+
16+
from tests.perf.microbenchmarks.parameters import IOBenchmarkParameters
17+
18+
19+
@dataclass
20+
class TimeBasedReadParameters(IOBenchmarkParameters):
21+
pattern: str
22+
duration: int
23+
warmup_duration: int
24+
num_ranges: int
25+
read_type: str

0 commit comments

Comments
 (0)