-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initialize Fiber
with an explicit stack
#15409
Initialize Fiber
with an explicit stack
#15409
Conversation
Doesn't change the public API (the stack is still taken from the current scheduler's stack pool), but introduces an undocumented initializer that takes the stack and stack_bottom pointers. This will allow a few scenarios, mostly for RFC 2: - start fibers with a fake stack when we don't need to run the fibers, for example during specs that only need fiber objects (and would leak memory since we only release stacks after the fiber has run); - during a cross execution context spawn, we can pick a stack from the destination context instead of the current context (so we can recycle stacks from fibers that terminated in the desination context).
issue: I'm wondering if we need protection to prevent injected stacks to end up in the pool. A possible solution for this problem would be to add a callback for releasing the stack. |
45f125a
to
9707185
Compare
@straight-shoota I tried to extract a Fiber::Stack struct that holds the stack limits, and a flag to tell whether the stack is reusable (i.e. shall be released back into stack pool). |
Doesn't change the public API (the stack is still taken from the current scheduler's stack pool), but introduces an undocumented initializer that takes the stack and stack_bottom pointers. This will allow a few scenarios, mostly for RFC 2: - start fibers with a fake stack when we don't need to run the fibers, for example during specs that only need fiber objects (and would leak memory since we only release stacks after the fiber has run); - during a cross execution context spawn, we can pick a stack from the destination context instead of the current context (so we can recycle stacks from fibers that terminated in the desination context).
Holds the stack limits and whether the stack can be reused (i.e. released back into Fiber::StackPool). Also abstracts accessing the first addressable pointer with 16-bytes alignment (as required by most architectures) to pass to `makecontext`.
9707185
to
aae3498
Compare
Co-authored-by: Johannes Müller <[email protected]>
It should be good now 🤞 |
question: What's the reason for reverting bytesize vs. bottom? I suppose it doesn't matter much either way, just curious. |
CI started failing with math overflow when creating the main fiber from the thread 🤷 |
Doesn't change the public API (the stack is still taken from the current scheduler's stack pool), but introduces an undocumented initializer that takes the stack and stack_bottom pointers.
This will allow a few scenarios, mostly for RFC 2:
Extracted from #15404
Follow up to #15434
Required by #15345