-
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
fs: ES6 Spread Operator for extended parameter handling #17486
Conversation
These sort of changes need benchmarks - have you tried running the benchmarks and getting results? |
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'm sorry but I'm strongly -1 on this change. This will be much slower than using apply
is.
@apapirovski : Thanks for the feedback. I'll close the PR. |
@apapirovski would still love some benchmarks |
@benjamingr I'm speaking from experience after trying to make this change on |
@apapirovski : Thanks for sharing that. Quite helpful 👍 |
@apapirovski can you send me a link to those benchmarks then? This is the third time we've been talking about whether or not spread is optimized or not and I want something concrete to go with when I bug V8 people about it :) |
@benjamingr the benchmarks are just the events ones... I think I saw the issue when working on |
I wish I had more info, it's just that I've been working on that stuff on-and-off for the past 2 months so it's a bit hard to recall at what point I encountered it. You could look over recent events, timers & process PRs potentially. |
@apapirovski @benjamingr : Just to mention, post closing the PR.. over my conversation with few JS experienced dev folks.. they did acknowledge too that |
ping @bmeurer any thoughts on |
FWIW I think the fastest combination here might be
When I test that version within @mithunsasidharan If you would like to try that version of the PR and run the relevant benchmarks in Here's the bench results after a short run:
Reasonably certain it's faster. Don't think it can land on v8.x or older though. |
Also, you could potentially test |
@apapirovski : Can you take a look at updated change here ? |
lib/fs.js
Outdated
@@ -145,8 +145,8 @@ function makeCallback(cb) { | |||
throw new errors.TypeError('ERR_INVALID_CALLBACK'); | |||
} | |||
|
|||
return function() { | |||
return cb.apply(undefined, arguments); | |||
return function(...arguments) { |
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.
This should be ...args
to match the variable below.
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.
@apapirovski : my bad.. will fix that !
lib/fs.js
Outdated
return function() { | ||
return cb.apply(undefined, arguments); | ||
return function(...arguments) { | ||
return cb.apply(undefined, args); |
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 that note, could we change this to Reflect.apply(cb, undefined, args);
? Thank you! That will mean we no longer depend on the user provided apply
.
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.
@apapirovski : Please take a look now. Thanks !
@apapirovski Yes I also think |
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 if CI & benchmark CI are happy.
@apapirovski : Thanks much ! |
LGTM |
Landed in 0a0fbd5 |
PR-URL: #17486 Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Benedikt Meurer <[email protected]> Reviewed-By: Timothy Gu <[email protected]>
PR-URL: #17486 Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Benedikt Meurer <[email protected]> Reviewed-By: Timothy Gu <[email protected]>
PR-URL: #17486 Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Benedikt Meurer <[email protected]> Reviewed-By: Timothy Gu <[email protected]>
Replaced
f.apply(undefined, arguments)
to ES 6f(...arguments)
Extended Parameter Handling Spread Operator inlib/fs.js
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
fs