Repository navigation
Processing: smaller stack frames, so tests run at the default stack (no RUST_MIN_STACK) - #296
Conversation
…no RUST_MIN_STACK) A debug build gives every temporary of an async fn its own slot in its poll's stack frame, a future it boxes at once included: `process` was one ~270 KB frame and `run` ~130 KB. Tests run queued jobs inline (a sync queue), so builds are processed inside the request that finalized them and inside each other, and the deepest tests needed up to 2080 KB, past the test threads' 2 MB. - `process` is now steps of their own (prepare, confirm, find_bases, compare_all, fill_in, warnings_of, settle), and `run` too (charge_before_run, process_exclusively, after_run). - `domain::boxed(|| step(..))` builds a step's future in a frame of its own, so the caller's frame holds a pointer. Used for those steps, `exclusive`, the conclusion's calls, carry-forward's compare, and finalize's dispatches and adopt. - .cargo/config.toml's `[env] RUST_MIN_STACK` is gone. The deepest test now needs 1576 KB; the whole suite passes at 1664 KB.
cd55cee to
f2d6a67
Compare
VisualCIdocspring/visualci · build #1432 · 578 unchanged · no changes This PR vs base: 26 changed since #1362, across 2 builds docspring/visualci · journeys · build #1429 · 6 removed, 53 unchanged · approved by visualci coordinator agent (MCP) for Nathan Broadbent
This PR vs base: 53 added, 47 removed since #1357, across 2 builds Removed: Updated as builds change. Agents can review with VisualCI's MCP tools. |
#279 added
.cargo/config.toml[env] RUST_MIN_STACK = "4194304"because the deepest app tests overflowed Rust's 2 MB test-thread stack. This PR removes it: every app test binary now passes at the default stack.Why the stack was deep
In a debug build, every temporary in an async fn's poll gets its own stack slot. That includes a future the function boxes straight away:
Box::pin(step(..))builds the future on the caller's stack before moving it to the heap. So an async fn that awaits many things gets a frame as big as all of them together.Tests run queued jobs and event listeners inline (a sync queue). A build is processed inside the request that finalized it, and builds are processed inside each other: the merge commit builds
finishedwakes, and a previous build thatadopt_on_branchorreruns::adoptfinalizes. So these frames stack up once per nested run.I measured the frames from the test binary's disassembly (each function's stack allocation). I also took a backtrace at the overflow, with each frame's size, from a temporary SIGSEGV handler on an alternate stack. The probes aren't in this PR.
processing::processconfirm52 KB,find_bases36 KB,fill_in36 KB,warnings_of57 KBprocessing::runcharge_before_run75 KB (runs before any nested work),after_run~2 KBhttp::api::builds::finalize(handler body)What changed (behaviour unchanged)
processis now a short list of steps, each its own async fn. Same order, same queries, same early returns.prepare: bundle readiness, the config item,reruns::follow,waits_for_previous.confirm: uploads and renders.find_bases.compare_all.fill_in: carry forward, the branch's unreviewed carry andkeep_rejections, sourced groups, removed rows, merged approvals. It returns theUnreviewedCarry.warnings_of.settle: the concluding transaction. It getshold: true when the previous build was unfinished, or whenmerge.holdis set.runis split the same way:charge_before_run.adopt_on_branch/reruns::startstep.process_exclusively: the lock and the one retry.after_run.domain::boxed(|| step(..))isBox::pin(make())with the future built in its own frame, so the caller's frame holds only a pointer. It's used for:exclusive→exclusive_with;charge_locked,concludeandbaselines::record(calls only:concludeitself is untouched);compare;finalize_shard,reruns::adoptand dispatches.domain::boxed,processandrunexplain why, so nobody inlines the steps again..cargo/config.toml: the[env] RUST_MIN_STACKblock and its comment are removed. The wasm target section stays.Measurements
The smallest
RUST_MIN_STACKeach test passes at, found by bisecting in 16 KB steps onmain(ff782a8) and on this branch. These are the 20 deepest tests on main.appbinary's 452 tests overflowed on main; 4 do on this branch.--test appbinary passes withRUST_MIN_STACK=1703936(1664 KB).Checks
cargo test -p visualci-apppasses with noRUST_MIN_STACKset: the lib's unit tests (69),app(452),live,live_limits,mcp_hosts,proxies,sentryandshutdown.cargo clippy --all-targets -- -D warningsandcargo fmt --checkpass.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.