-
Notifications
You must be signed in to change notification settings - Fork 168
feat: Add micro-benchmarks for writes comparing standard (regional) vs rapid (zonal) buckets. #1707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
chandra-siri
wants to merge
9
commits into
bench
Choose a base branch
from
bench_writes
base: bench
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
6d88a15
Add writes benchmarking
chandra-siri 016dfbe
Merge branch 'bench' of github.com:googleapis/python-storage into ben…
chandra-siri 3f76aab
fix: update config file path in write parameters and adjust import st…
chandra-siri 17fc801
fix: correct import path for WriteParameters in config.py
chandra-siri 0a9d185
fix: update bucket_map to use environment variables for default bucke…
chandra-siri 3f0b1c2
Merge branch 'bench' of github.com:googleapis/python-storage into ben…
chandra-siri 7c7808e
update README and test_writes.py with detailed usage examples and enh…
chandra-siri 0066029
refactor: simplify num_files calculation and clean up imports in writ…
chandra-siri 042c60b
refactor: enhance docstring for get_write_params function to clarify …
chandra-siri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| # Copyright 2026 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| import itertools | ||
| import os | ||
| from typing import Dict, List | ||
|
|
||
| import yaml | ||
|
|
||
| try: | ||
| from tests.perf.microbenchmarks.writes.parameters import WriteParameters | ||
| except ModuleNotFoundError: | ||
| from parameters import WriteParameters | ||
|
|
||
|
|
||
| def get_write_params() -> Dict[str, List[WriteParameters]]: | ||
| """Generates benchmark parameters from a YAML configuration file. | ||
|
|
||
| This function reads the configuration from `config.yaml`, located in the | ||
| same directory, and generates all possible combinations of write parameters | ||
| based on the defined workloads. It uses `itertools.product` to create | ||
| a Cartesian product of parameters like bucket types, file sizes, etc. | ||
|
|
||
| Returns: | ||
| Dict[str, List[WriteParameters]]: A dictionary where keys are workload | ||
| names and values are lists of `WriteParameters` instances for that | ||
| workload. | ||
| """ | ||
| params: Dict[str, List[WriteParameters]] = {} | ||
| config_path = os.path.join(os.path.dirname(__file__), "config.yaml") | ||
| with open(config_path, "r") as f: | ||
| config = yaml.safe_load(f) | ||
|
|
||
| common_params = config["common"] | ||
| bucket_types = common_params["bucket_types"] | ||
| file_sizes_mib = common_params["file_sizes_mib"] | ||
| chunk_sizes_mib = common_params["chunk_sizes_mib"] | ||
| rounds = common_params["rounds"] | ||
|
|
||
| bucket_map = { | ||
| "zonal": os.environ.get("DEFAULT_RAPID_ZONAL_BUCKET", config['defaults']['DEFAULT_RAPID_ZONAL_BUCKET']), | ||
| "regional": os.environ.get("DEFAULT_STANDARD_BUCKET", config['defaults']['DEFAULT_STANDARD_BUCKET']) | ||
| } | ||
|
|
||
| for workload in config["workload"]: | ||
| workload_name = workload["name"] | ||
| params[workload_name] = [] | ||
| processes = workload["processes"] | ||
| coros = workload["coros"] | ||
|
|
||
| # Create a product of all parameter combinations | ||
| product = itertools.product( | ||
| bucket_types, | ||
| file_sizes_mib, | ||
| chunk_sizes_mib, | ||
| processes, | ||
| coros, | ||
| ) | ||
|
|
||
| for ( | ||
| bucket_type, | ||
| file_size_mib, | ||
| chunk_size_mib, | ||
| num_processes, | ||
| num_coros, | ||
| ) in product: | ||
| file_size_bytes = file_size_mib * 1024 * 1024 | ||
| chunk_size_bytes = chunk_size_mib * 1024 * 1024 | ||
| bucket_name = bucket_map[bucket_type] | ||
|
|
||
| num_files = num_processes * num_coros | ||
|
|
||
| # Create a descriptive name for the parameter set | ||
| name = f"{workload_name}_{bucket_type}_{num_processes}p_{num_coros}c" | ||
|
|
||
| params[workload_name].append( | ||
| WriteParameters( | ||
| name=name, | ||
| workload_name=workload_name, | ||
| bucket_name=bucket_name, | ||
| bucket_type=bucket_type, | ||
| num_coros=num_coros, | ||
| num_processes=num_processes, | ||
| num_files=num_files, | ||
| rounds=rounds, | ||
| chunk_size_bytes=chunk_size_bytes, | ||
| file_size_bytes=file_size_bytes, | ||
| ) | ||
| ) | ||
| return params |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| common: | ||
| bucket_types: | ||
| - "regional" | ||
| - "zonal" | ||
| file_sizes_mib: | ||
| - 1024 # 1GiB | ||
| chunk_sizes_mib: [100] | ||
| rounds: 10 | ||
|
|
||
| workload: | ||
|
|
||
| ############# single proc single coroutines ######### | ||
| - name: "write_seq" | ||
| pattern: "seq" | ||
| coros: [1] | ||
| processes: [1] | ||
|
|
||
| ############# single proc multiple coroutines ######### | ||
|
|
||
| - name: "write_seq_multi_coros" | ||
| pattern: "seq" | ||
| coros: [2, 4, 8, 16] | ||
| processes: [1] | ||
|
|
||
| ############# multiple proc multiple coroutines ######### | ||
| - name: "write_seq_multi_process" | ||
| pattern: "seq" | ||
| coros: [1, 2] | ||
| processes: [8, 16, 32, 64] | ||
|
|
||
|
|
||
| defaults: | ||
| DEFAULT_RAPID_ZONAL_BUCKET: "chandrasiri-benchmarks-zb" | ||
| DEFAULT_STANDARD_BUCKET: "chandrasiri-benchmarks-rb" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Copyright 2026 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| from dataclasses import dataclass | ||
| from ..parameters import IOBenchmarkParameters | ||
|
|
||
|
|
||
| @dataclass | ||
| class WriteParameters(IOBenchmarkParameters): | ||
| pass |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.