-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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
timers: improve setImmediate() performance #8655
Conversation
|
||
|
||
function processImmediate() { | ||
const queue = immediateQueue; | ||
var domain, immediate; | ||
var p = immediateQueue.head; |
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.
p
is poorly named
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.
Changed to ptr
. Is that sufficient?
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.
why not just keep it as immediate
?
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.
Done.
5f4c590
to
a284f41
Compare
a284f41
to
dcc9fe0
Compare
I've now tweaked a few of the functions used by |
@@ -45,6 +45,21 @@ function setupPromises(scheduleMicrotasks) { | |||
} | |||
} | |||
|
|||
function emitWarning() { | |||
const warning = new Error('Unhandled promise rejection ' + | |||
`(rejection id: ${uid}): ${reason}`); |
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.
uid
and reason
not defined here.
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.
Fixed.
dcc9fe0
to
e66340a
Compare
CI again again: https://ci.nodejs.org/job/node-test-pull-request/4143/ |
'Node.js process with a non-zero exit code.', | ||
'DeprecationWarning'); | ||
} | ||
emitWarning(uid, reason); |
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.
@mscdex err, why is this included?
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.
To allow for more inlining. emitPendingUnhandledRejections()
is used by setImmediate()
.
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.
LGTM
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.
LGTM
ping @Fishrock123 ... does this LGTY? |
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.
Functionality LGTM, I'd like some commenting around the new linkedlist stuff personally, I find them notoriously hard to read / understand and I doubt I am alone.
OK otherwise if CI passes.
|
||
immediateQueue = L.create(); | ||
immediateQueue.head = immediateQueue.tail = null; |
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.
a comment would be helpful
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.
What did you have in mind? To me it's self-explanatory, it's effectively clearing the linked list.
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 know what it does, I think it just may look strange to someone else encountering it.
immediateQueue.head = next; | ||
} else { | ||
immediateQueue.head = next; | ||
immediateQueue.tail = oldTail; |
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.
Can this be a helper fn?
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.
What do you mean?
this.head = item; | ||
} | ||
this.tail = item; | ||
}; |
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 probably should specify: comments on how these two modify their respective properties
e66340a
to
67f1a2a
Compare
@Fishrock123 Comments added, let me know if they are sufficient. |
ping @Fishrock123 |
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.
lgtm
CI before landing: https://ci.nodejs.org/job/node-test-pull-request/4389/ EDIT: checking again after rebasing just to be sure flakiness is unrelated: https://ci.nodejs.org/job/node-test-commit/5451/ |
67f1a2a
to
1bb9048
Compare
This commit avoids re-creating a new immediate queue object every time the immediate queue is processed. Additionally, a few functions are tweaked to make them inlineable. These changes give ~6-7% boost in setImmediate() performance in the existing setImmediate() benchmarks. PR-URL: nodejs#8655 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
1bb9048
to
0ed8839
Compare
This commit avoids re-creating a new immediate queue object every time the immediate queue is processed. Additionally, a few functions are tweaked to make them inlineable. These changes give ~6-7% boost in setImmediate() performance in the existing setImmediate() benchmarks. PR-URL: #8655 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
adding to lts watch but unsure if this should land. Will definitely need time to sit in a release for a while /cc @mscdex |
This commit avoids re-creating a new immediate queue object every time the immediate queue is processed. Additionally, a few functions are tweaked to make them inlineable. These changes give ~6-7% boost in setImmediate() performance in the existing setImmediate() benchmarks. PR-URL: #8655 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Conflicts: lib/internal/process/promises.js
Hey there! We started having test failures due to this change. There's more information on the issue & PR linked just above this comment. To pull some of that here:
We have a temporary fix in place in the PR, that reduces the timeout and this appears to work (the tests pass). Would love a little bit of input into how this change has impacted the functionality and whether we've found a bug or are doing something wrong :) |
/cc @nodejs/ctc |
@ErisDS I don't suppose you have a minimal test that could be used to demonstrate the immediate running in v6.7.0 and not running in v6.8.0, do you? I'm guessing not because you probably would have mentioned it, but I'm having trouble replicating the problem, probably because I am Doing Something Wrong. |
@Trott i will provide an example file asap |
|
Moving to a new issue so we can help you better: #9084 please put all comments in that thread rather than here |
Checklist
make -j4 test
(UNIX), orvcbuild test nosign
(Windows) passesAffected core subsystem(s)
Description of change
This commit avoids re-creating a new immediate queue object every time the immediate queue is processed. Additionally, a few functions are tweaked to make them inlineable.
These changes result in ~6-7% improvement in the existing
setImmediate()
benchmarks and should help reduce GC work.