-
Notifications
You must be signed in to change notification settings - Fork 30k
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
process: code cleanup for nextTick #28047
Conversation
This comment has been minimized.
This comment has been minimized.
ba15880
to
e4ecfe2
Compare
Fix a few edge cases and non-obvious issues with nextTick: 1. Emit destroy hook in a try-finally rather than triggering it before the callback runs. 2. Re-word comment for processPromiseRejections and make sure it returns true in the rejectionHandled case too. 3. Small readability improvements.
e4ecfe2
to
1a66c0d
Compare
This comment has been minimized.
This comment has been minimized.
@apapirovski would it be possible to write a test case for the destroy hook change? |
function processPromiseRejections() { | ||
let maybeScheduledTicksOrMicrotasks = asyncHandledRejections.length > 0; |
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.
On a side note, I wonder if it make sense now to just merge process/promises.js
and process/task_queues.js
- the latter is currently the only one who requires the former.
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.
Maybe? At the same time it's a little easier to read the task queue code as is. Also, the code in promises isn't really explicitly tied to task queues.
If someone feels strongly, they should open a PR. I, personally, like it as is.
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.
Keep in mind, more files = more startup time.
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.
@Fishrock123 This is now somewhat negligible since we have shipped pre-built code cache for builtin modules, which eliminates the majority of the overhead of loading an builtin module (compilation) - of course that does not apply to modules like internal/errors.js
which does a lot of stuff in the initialization, but that overhead would be eliminated as well when the v8 snapshot integration is completed.
@BridgeAR added a test, as requested. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Worth a benchmark run? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Timers benchmark with this PR: https://ci.nodejs.org/view/All/job/benchmark-node-micro-benchmarks/392/ |
Fix a few edge cases and non-obvious issues with nextTick: 1. Emit destroy hook in a try-finally rather than triggering it before the callback runs. 2. Re-word comment for processPromiseRejections and make sure it returns true in the rejectionHandled case too. 3. Small readability improvements. PR-URL: nodejs#28047 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Landed in abf765e |
Fix a few edge cases and non-obvious issues with nextTick: 1. Emit destroy hook in a try-finally rather than triggering it before the callback runs. 2. Re-word comment for processPromiseRejections and make sure it returns true in the rejectionHandled case too. 3. Small readability improvements. PR-URL: #28047 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Fix a few edge cases and non-obvious issues with nextTick:
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes