Skip to content

Conversation

@chandra-siri
Copy link
Collaborator

feat: run benchmarks in CI

@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: storage Issues related to the googleapis/python-storage API. labels Jan 25, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @chandra-siri, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request integrates microbenchmarks into the continuous integration system. It establishes a new Cloud Build pipeline that provisions a Google Compute Engine virtual machine, sets up the necessary environment, and executes a defined set of performance tests. This ensures that performance characteristics are regularly monitored and potential regressions are identified early in the development cycle.

Highlights

  • New CI Configuration: A new Cloud Build configuration file, cloudbuild/micro_benchmarks.yaml, has been added to automate the execution of microbenchmarks within the CI pipeline.
  • Benchmark Execution Script: A dedicated shell script, cloudbuild/run_micro_benchmarks.sh, was introduced to handle the setup of a Google Compute Engine (GCE) VM, repository cloning, dependency installation, and execution of performance tests on the VM.
  • Optimized Benchmark Parameters: Benchmark parameters in tests/perf/microbenchmarks/reads/config.yaml were adjusted to optimize for CI, specifically by reducing file sizes, chunk sizes, and the number of test rounds, and focusing on zonal buckets for quicker execution.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new CI job for running micro-benchmarks, which is a valuable addition for performance tracking. The implementation is mostly solid, but I've found a few issues that need to be addressed. There's a critical issue in the Cloud Build configuration where the wrong script is being executed, and another bug related to handling the exit code. I've also suggested some improvements to the test execution script and a minor fix in the benchmark configuration file to enhance maintainability and test coverage.

# Execute the script on the VM via SSH.
# Capture the exit code to ensure cleanup happens before the build fails.
set +e
gcloud compute ssh ${_VM_NAME} --zone=${_ZONE} --internal-ip --ssh-key-file=/workspace/.ssh/google_compute_engine --command="ulimit -n {_ULIMIT}; COMMIT_SHA=${COMMIT_SHA} _ZONAL_BUCKET=${_ZONAL_BUCKET} _PR_NUMBER=${_PR_NUMBER} bash run_zonal_tests.sh"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The script being executed on the VM is run_zonal_tests.sh, but the script that was copied to the VM in the previous step is run_micro_benchmarks.sh. This will cause the wrong tests to be executed. You should execute run_micro_benchmarks.sh instead.

        gcloud compute ssh ${_VM_NAME} --zone=${_ZONE} --internal-ip --ssh-key-file=/workspace/.ssh/google_compute_engine --command="ulimit -n {_ULIMIT}; COMMIT_SHA=${COMMIT_SHA} _ZONAL_BUCKET=${_ZONAL_BUCKET} _PR_NUMBER=${_PR_NUMBER} bash run_micro_benchmarks.sh"

gcloud compute instances delete "${_VM_NAME}" --zone=${_ZONE} --quiet
# Exit with the original exit code from the test script.
exit $$EXIT_CODE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The expression $$EXIT_CODE is incorrect. $$ expands to the process ID of the current shell, so this command will effectively try to exit with a code like 123$?. You should use $EXIT_CODE to correctly use the captured exit code from the test script.

        exit $EXIT_CODE

Comment on lines +28 to +32
pytest -vv -s \
--log-format='%(asctime)s %(levelname)s %(message)s' \
--log-date-format='%H:%M:%S' \
--benchmark-json=output.json \
-vv -s tests/perf/microbenchmarks/reads/test_reads.py::test_downloads_single_proc_single_coro
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The pytest command has duplicated flags (-vv and -s). While this doesn't cause an error, it's redundant. Additionally, only a single test function is being run. Given that the benchmark configuration in config.yaml has been scaled down, it would be beneficial to run all tests in test_reads.py to get broader benchmark coverage in CI.

Suggested change
pytest -vv -s \
--log-format='%(asctime)s %(levelname)s %(message)s' \
--log-date-format='%H:%M:%S' \
--benchmark-json=output.json \
-vv -s tests/perf/microbenchmarks/reads/test_reads.py::test_downloads_single_proc_single_coro
pytest -vv -s \
--log-format='%(asctime)s %(levelname)s %(message)s' \
--log-date-format='%H:%M:%S' \
--benchmark-json=output.json \
tests/perf/microbenchmarks/reads/test_reads.py

- 1024 # 1GiB
chunk_sizes_mib: [100]
rounds: 10
- 100 # 1GiB
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The comment # 1GiB is no longer accurate since the file size has been changed to 100 MiB. Please update the comment to reflect the new value to avoid confusion.

    - 100 # 100MiB

@chandra-siri
Copy link
Collaborator Author

/gcbrun(5fc8fcd)

@chandra-siri
Copy link
Collaborator Author

/gcbrun(2f13bb8)

@chandra-siri
Copy link
Collaborator Author

/gcbrun(8594296)

@chandra-siri
Copy link
Collaborator Author

/gcbrun(bc6bf69)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: storage Issues related to the googleapis/python-storage API. size: m Pull request size is medium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant