RFC 2 : Delay Fiber stack association #15404
Closed
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.
Fiber#initialize
now takes an explicit stack. The public API doesn't change, and we can still create aFiber
without an explicit stack, taken from the current scheduler/context's stack pool.Fiber::ExecutionContext#spawn
takes advantage of this to take a stack from the execution context's stack pool, instead of the current context's stack pool. Cross context spawns thus won't take a stack from context A but release the stack in context B (where it actually ran) which would prevent stack recycling.This also permits to create lots of Fiber instances in specs using a minimal fake stack, instead of requesting 8MB of virtual memory for each fiber, despite the fibers never running... which is leaking memory because we only release the stacks when the fiber terminates.
Follow up to #15345 and #15350