-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Reduce fiber switches by queuing callbacks for each tick #34
Conversation
This fixes one delay callback triggering a signal and the next tick hanging then without dispatching the signal.
This avoids two additional fiber switches per tick for non-blocking ticks.
@WyriHaximus FYI, this has a noticeable performance improvement (+10% to 15% on an HTTP server test) when many watchers are set to be invoked within a single tick. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this change a lot - thanks for the effort :-)
@trowski I'm seeing 24-25% performance improvement instead of 10-15% for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work 👍
Wow! Even better! I was running a debug build of PHP, so take my benchmark with a grain of salt. 😁 |
This massively reduces the number of fibers switches. Before, we usually had a switch to the event loop, another to the callback fiber, called
Suspension::resume()
, switched back to the event loop, switched to the microtask fiber, switched to the fiber that suspended to await an event. Now we switch to the event loop, switch to the callback fiber once per tick (if non-blocking and there's no suspend within the callback) and switch to the original fiber.