refactor(storage): modularize object samples to prevent stack overflow - #6660
refactor(storage): modularize object samples to prevent stack overflow#6660vsharonlynn wants to merge 1 commit into
Conversation
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).
There was a problem hiding this comment.
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.
| let result = Box::pin(run_object_examples(&mut buckets)) | ||
| .await | ||
| .inspect_err(anydump); |
There was a problem hiding this comment.
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
No description provided.