-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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: improve performance of nextTick #8932
Conversation
Interesting, there is a few places we moved to constructors for previous optimizations, perhaps we should be moving away now? |
@Fishrock123 possibly. Hopefully, I'll be digging some other areas as well this week. I was planning on looking at immediates next, so I'll probably have some questions for you :] I also need to test on v6.x and see if there are any differences since we updated to V8 5.1 |
@@ -151,7 +145,11 @@ function setupNextTick() { | |||
args[i - 1] = arguments[i]; | |||
} | |||
|
|||
nextTickQueue.push(new TickObject(callback, args)); | |||
nextTickQueue.push({ | |||
callback: callback, |
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.
Just out of curiosity, is there a particular reason not to go
nextTickQueue.push({
args,
callback,
domain: process.domain || 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.
I just find it less readable than the way it currently 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.
Prefer what @claudiorodriguez suggested
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.
ack
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.
assuming it does not alter perf that 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.
it doesn't appear to make a difference. Just ran again using shorthand and the numbers are more or less the same. :]
Great work. Nice to see that you are using the new benchmarking tool. However you shouldn't do many independent For each comparison you do, there is by default a 5% risk that we see a significant result when there in reality no improvement. By doing 3 runs you increase that risk to |
@AndreasMadsen thanks for the info. I ran the bench again once with 100 runs this time and got very similar results:
Should I be doing these runs once for each benchmark script? |
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
I'd like to see some info on what branches this can effectively go to before we land it though :) |
@Fishrock123 yea, am going to bench on v6.x now |
(pending checks are a bug -- i need to cover skipped status) |
results for v6.x:
|
Not sure what you mean. But it looks like you did it correctly 👍 |
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
Oh, what I meant to say is LATM. Looks Awesome To Me. |
LGTM |
Running CI one more time since I updated it: https://ci.nodejs.org/job/node-test-pull-request/4403/ |
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
LGTM. Though we shouldn't put much on the breadth tests. 99% of the time the nextTickQueue array has fewer than 5 callbacks when processed. |
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
I am going to benchmark on v4.x tonight to see if it is even worth it there as well. |
So, for v4, I had to use the old benchmarks. It doesn't seem to make as much of a difference as on v6.
so, we can probably just not backport this to v4.x |
79c679d
to
fc514fd
Compare
@evanlucas you are supposed to be able to use the new benchmarking suite on old node versions. The process is: git checkout upstream/v4.x-staging # or similar branch
make -j8
cp ./node ./node-v4
apply-pr 8932 # fix the file missing conflict
make -j8
cp ./node ./node-v4-pr8932
git checkout master
make -j4 # or just use your globally installed version
./node ./benchmark/compare.js \
--old ./node-v4 --new ./node-v4-pr8932 \
--filter next-tick -- process | tee results.csv
cat results.csv | Rscript ./benchmark/compare.R Unfortunately some new syntax has sneaked into common.js. Replacing This gives the result (30 runs):
|
This replaces TickObject with an object literal. This offers performance improvements of up to ~20%. PR-URL: nodejs#8932 Reviewed-By: Claudio Rodriguez <cjrodr@yahoo.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Johan Bergström <bugs@bergstroem.nu> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
fc514fd
to
804d57d
Compare
Landed in 804d57d. Thanks! |
This replaces TickObject with an object literal. This offers performance improvements of up to ~20%. PR-URL: #8932 Reviewed-By: Claudio Rodriguez <cjrodr@yahoo.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Johan Bergström <bugs@bergstroem.nu> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Using new syntax such as `...args` means that the benchmark suite can't be used with older node versions. This changes the `...args` syntax to a good old `Array.prototype.slice`. Refs: #8932 (comment) PR-URL: #9064 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net>
Using new syntax such as `...args` means that the benchmark suite can't be used with older node versions. This changes the `...args` syntax to a good old `Array.prototype.slice`. Refs: #8932 (comment) PR-URL: #9064 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net>
@evanlucas how long should we be letting this live on v7 before backporting? |
It's a pretty small change so it doesn't really matter to me. I think it should be fine to get in to the next v6.x release if no one objects |
This does not land cleanly in LTS v4.x. Added dont-land label. Please feel free to manually backport |
This replaces TickObject with an object literal. This offers performance improvements of up to ~20%. PR-URL: #8932 Reviewed-By: Claudio Rodriguez <cjrodr@yahoo.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Johan Bergström <bugs@bergstroem.nu> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
This replaces TickObject with an object literal. This offers performance improvements of up to ~20%. PR-URL: #8932 Reviewed-By: Claudio Rodriguez <cjrodr@yahoo.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Johan Bergström <bugs@bergstroem.nu> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Backport for v4.x can be found at #10433. Thanks! |
This LTS release comes with 312 commits. This includes 229 that are test related, 62 that are docs related, 17 which are build / tools related, and 4 commits which are updates to dependencies. Notable Changes: * build: - shared library support is now working for AIX builds (Stewart Addison) #9675 * deps: - *npm*: upgrade npm to 3.10.10 (Rebecca Turner) #9847 - *V8*: Destructuring of arrow function arguments via computed property no longer throws (Michaël Zasso) #10386) * inspector: - /json/version returns object, not an object wrapped in an array (Ben Noordhuis) #9762 * module: - using --debug-brk and --eval together now works as expected (Kelvin Jin) #8876 * process: - improve performance of nextTick up to 20% (Evan Lucas) #8932 * repl: - the division operator will no longer be accidentally parsed as regex (Teddy Katz) #10103 - improved support for generator functions (Teddy Katz) #9852 * timers: - Re canceling a cancelled timers will no longer throw (Jeremiah Senkpiel) #9685 PR-URL: #10394
This LTS release comes with 312 commits. This includes 229 that are test related, 62 that are docs related, 17 which are build / tools related, and 4 commits which are updates to dependencies. Notable Changes: * build: - shared library support is now working for AIX builds (Stewart Addison) #9675 * deps: - *npm*: upgrade npm to 3.10.10 (Rebecca Turner) #9847 - *V8*: Destructuring of arrow function arguments via computed property no longer throws (Michaël Zasso) #10386) * inspector: - /json/version returns object, not an object wrapped in an array (Ben Noordhuis) #9762 * module: - using --debug-brk and --eval together now works as expected (Kelvin Jin) #8876 * process: - improve performance of nextTick up to 20% (Evan Lucas) #8932 * repl: - the division operator will no longer be accidentally parsed as regex (Teddy Katz) #10103 - improved support for generator functions (Teddy Katz) #9852 * timers: - Re canceling a cancelled timers will no longer throw (Jeremiah Senkpiel) #9685 PR-URL: #10394
This LTS release comes with 312 commits. This includes 229 that are test related, 62 that are docs related, 17 which are build / tools related, and 4 commits which are updates to dependencies. Notable Changes: * build: - shared library support is now working for AIX builds (Stewart Addison) nodejs/node#9675 * deps: - *npm*: upgrade npm to 3.10.10 (Rebecca Turner) nodejs/node#9847 - *V8*: Destructuring of arrow function arguments via computed property no longer throws (Michaël Zasso) nodejs/node#10386) * inspector: - /json/version returns object, not an object wrapped in an array (Ben Noordhuis) nodejs/node#9762 * module: - using --debug-brk and --eval together now works as expected (Kelvin Jin) nodejs/node#8876 * process: - improve performance of nextTick up to 20% (Evan Lucas) nodejs/node#8932 * repl: - the division operator will no longer be accidentally parsed as regex (Teddy Katz) nodejs/node#10103 - improved support for generator functions (Teddy Katz) nodejs/node#9852 * timers: - Re canceling a cancelled timers will no longer throw (Jeremiah Senkpiel) nodejs/node#9685 PR-URL: nodejs/node#10394 Signed-off-by: Ilkka Myller <ilkka.myller@nodefield.com>
This LTS release comes with 312 commits. This includes 229 that are test related, 62 that are docs related, 17 which are build / tools related, and 4 commits which are updates to dependencies. Notable Changes: * build: - shared library support is now working for AIX builds (Stewart Addison) nodejs/node#9675 * deps: - *npm*: upgrade npm to 3.10.10 (Rebecca Turner) nodejs/node#9847 - *V8*: Destructuring of arrow function arguments via computed property no longer throws (Michaël Zasso) nodejs/node#10386) * inspector: - /json/version returns object, not an object wrapped in an array (Ben Noordhuis) nodejs/node#9762 * module: - using --debug-brk and --eval together now works as expected (Kelvin Jin) nodejs/node#8876 * process: - improve performance of nextTick up to 20% (Evan Lucas) nodejs/node#8932 * repl: - the division operator will no longer be accidentally parsed as regex (Teddy Katz) nodejs/node#10103 - improved support for generator functions (Teddy Katz) nodejs/node#9852 * timers: - Re canceling a cancelled timers will no longer throw (Jeremiah Senkpiel) nodejs/node#9685 PR-URL: nodejs/node#10394 Signed-off-by: Ilkka Myller <ilkka.myller@nodefield.com>
Checklist
make -j8 test
(UNIX), orvcbuild test nosign
(Windows) passesAffected core subsystem(s)
process
Description of change
This replaces TickObject with an object literal. This offers
performance improvements of up to ~20%.
Results from a few benchmark runs:
/cc @trevnorris since you added TickObject