Repository navigation
Worker: box each event's future so it never overflows the main thread's stack - #678
Merged
Merged
Conversation
…'s stack Every wrapper around a pass (a task-local scope, the run ceiling, the stop watch) held the pass's future inline, so the event future was about 3 MB and was built on Lambda's 8 MB main thread stack before anything boxed it. v0.8.108's few extra kilobytes per layer pushed it over: every invocation died with SIGSEGV. The handler, the SQS message and the message's pass are now boxed, and a test holds each entry point's future under 64 KiB.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Since v0.8.108 every worker invocation dies about 360 ms in with
signal: segmentation fault: a stack overflow on the main thread. The event's future was never boxed, and each wrapper around a pass (a task-local scope, the run ceiling, the stop watch) held the pass's future inline, so the futurehandle_eventreturns was about 3 MB (3,060,784 bytes at v0.8.107, 3,169,840 at v0.8.108) and was built and moved on Lambda's 8 MB main thread stack. v0.8.107 fit with little room; the passes #671 and #672 added pushed it over.Changes
services/worker/src/main.rs: the handler's future, the plan chat call, the SQS message'shandle_messageand itshandle_message_innerare boxed where they are awaited. Each entry point's future is now small; the passes run from the heap.future_sizes::entry_points_stay_small, holdshandle_event,handle_sqsandhandle_messageunder 64 KiB. It fails on main (about 3 MB). The budget incident test reads the boxed call.Verification
model_checkevent, with the main thread stack set byulimit -s:cargo fmt --check --all,cargo clippy --workspace --all-targets -- -D warnings,cargo test --workspace.