RFC 2 : Delay Fiber stack association#15404
Closed
ysbaddaden wants to merge 7 commits intocrystal-lang:masterfrom
Closed
RFC 2 : Delay Fiber stack association#15404ysbaddaden wants to merge 7 commits intocrystal-lang:masterfrom
ysbaddaden wants to merge 7 commits intocrystal-lang:masterfrom
Conversation
`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.
This was referenced Jan 16, 2025
Collaborator
Author
|
Allright: it eventually passed on mingw64 too. |
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.
Fiber#initializenow takes an explicit stack. The public API doesn't change, and we can still create aFiberwithout an explicit stack, taken from the current scheduler/context's stack pool.Fiber::ExecutionContext#spawntakes 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