Skip to content

refactor(storage): modularize object samples to prevent stack overflow - #6660

Draft
vsharonlynn wants to merge 1 commit into
googleapis:mainfrom
vsharonlynn:refactor-storage-samples-stack
Draft

refactor(storage): modularize object samples to prevent stack overflow#6660
vsharonlynn wants to merge 1 commit into
googleapis:mainfrom
vsharonlynn:refactor-storage-samples-stack

Conversation

@vsharonlynn

Copy link
Copy Markdown
Contributor

No description provided.

In unoptimized debug builds (`-C opt-level=0`), the monolithic
`run_object_examples` function generated a single async state machine
frame of ~1.22 MB, which exhausted the 2 MB test thread stack during
nested HTTP and TLS operations in integration tests.

Break `run_object_examples` into smaller domain-specific async helper
functions, box concurrent object creation futures with `Box::pin`, and
box the top-level test runner future. This reduces the prologue stack
frame from 1.22 MB to ~363 KB (~70% reduction).
@product-auto-label product-auto-label Bot added api: storage Issues related to the Cloud Storage API. samples Issues that are directly related to samples. labels Sep 4, 2026

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

Copy link
Copy Markdown
Contributor

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 refactors the run_object_examples function in src/storage/examples/src/lib.rs by modularizing its contents into several smaller helper functions. In the integration tests, the call to run_object_examples was wrapped in Box::pin. However, because of the modularization, the future size of run_object_examples is now significantly smaller, making Box::pin unnecessary. It is recommended to await the function directly.

Comment on lines +76 to +78
let result = Box::pin(run_object_examples(&mut buckets))
.await
.inspect_err(anydump);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Now that run_object_examples has been modularized into smaller functions, the size of its future is extremely small. Therefore, wrapping it in Box::pin to prevent stack overflow is no longer necessary. We can await it directly, matching the pattern used by all other integration tests in this file.

        let result = run_object_examples(&mut buckets).await.inspect_err(anydump);

@codecov

codecov Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.56%. Comparing base (7a32efa) to head (b8ffeb2).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6660      +/-   ##
==========================================
- Coverage   96.57%   96.56%   -0.01%     
==========================================
  Files         307      307              
  Lines       94431    94431              
==========================================
- Hits        91196    91192       -4     
- Misses       3235     3239       +4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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 Cloud Storage API. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant