-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Alternative Fiber Internals Refactoring #7101
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
Conversation
Hey @kooldev, this looks like a fantastic starting point for further improvements. This looks ready to merge IMO. Should we merge this and do another PR using |
Hey @trowski, glad you like it. I am pretty sure that this refactoring is a also a nice step towards making it compatible with a future version of Swoole. I think it will be best to rearrange the BTW: How do you test that ASAN thingy? (I am doing testing in a debian-based docker container) |
I'd like at least one more review before merging in case I missed something. You can test with ASan by adding |
Thank you for your work. |
We can look at how we might want to combine The main fiber has a simple implementation here without hacking it onto the VM stack to avoid an alloc. Providing both symmetric and asymmetric fiber switching models in the internal API is a fine compromise IMO if it means better collaboration or usability. Most of the conversation in the last PR was just about getting you to understand there was a slight paradigm shift being made. |
We don't need symmetric fiber model and we can't, we just need the way to replace the main with a fiber. |
I've grown tired of arguing this point. I'll merge this PR and we can move forward with further changes from here. I'd like to see the unified API @kooldev has in mind. |
@trowski This is an alternative (and a lot simpler refactoring) to #7085 that achieves some of the goals (1 and 3) stated by @twose without a complete rewrite of the code. I kept everything really simple to make it easily comprehensible. It also allows for pure C fibers and arbitrary context switching for different scheduling models. The C fiber is basically represented by
zend_fiber_context
while the PHP fiber object is usingzend_fiber
. I am pretty sure that it is a good starting point for further improvements. I have used similiar in production for more than a year now and it works really well.I did not remove the
ZEND_API
forzend_fiber
, however it would make sense to come up with a new implementation based onzend_fiber_context
that might be more suited for internal use. I have used an API like that for some time and it was really nice for suspending from within PHP streams and function calls. Let me know if you are intereseted in another PR for this and I will try to come up with another PR.Let's make this work in a way that allows everyone to collaborate and benefit.