| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
These sort of changes need benchmarks - have you tried running the benchmarks and getting results? |
Sorry, something went wrong.
There was a problem hiding this comment.
I'm sorry but I'm strongly -1 on this change. This will be much slower than using apply is.
Sorry, something went wrong.
|
@apapirovski : Thanks for the feedback. I'll close the PR. |
Sorry, something went wrong.
|
@apapirovski would still love some benchmarks |
Sorry, something went wrong.
|
@benjamingr I'm speaking from experience after trying to make this change on events and having the benchmarks be roughly 20-25% slower in certain situations. Theoretically this is supposed to be optimized (a basic benchmark shows maybe 2-3% perf gap and that might just be noise), practically there seem to be edge cases. |
Sorry, something went wrong.
|
@apapirovski : Thanks for sharing that. Quite helpful 👍 |
Sorry, something went wrong.
|
@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 :) |
Sorry, something went wrong.
|
@benjamingr the benchmarks are just the events ones... I think I saw the issue when working on once or something similar. It's also possible it might've been in process.nextTick or timers. I can try to reproduce again when I have a moment. |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
|
@apapirovski @benjamingr : Just to mention, post closing the PR.. over my conversation with few JS experienced dev folks.. they did acknowledge too that f.apply(undefined, arguments); is much better performant than f(...arguments); in multiple different scenarios and they did confirm they've tested it ! |
Sorry, something went wrong.
|
ping @bmeurer any thoughts on fn(...arguments) vs fn.apply(undefined, arguments)? I'm almost certain I've run into edge cases before but I also know the V8 team has done work to optimize this recently? |
Sorry, something went wrong.
|
FWIW I think the fastest combination here might be function(...args) {
return cb.apply(undefined, args);
}
When I test that version within once with ee-once benchmark, it's about 5% faster than using arguments. Don't ask me why... @mithunsasidharan If you would like to try that version of the PR and run the relevant benchmarks in benchmark/fs then that PR could probably be accepted? Here's the bench results after a short run: fs/bench-readdir.js n=10000 1.95 % *** 0.0006178907 Reasonably certain it's faster. Don't think it can land on v8.x or older though. |
Sorry, something went wrong.
|
Also, you could potentially test fn(...args) { return cb(...args); }? It might be the same. Not sure. |
Sorry, something went wrong.
|
@apapirovski : Can you take a look at updated change here ? |
Sorry, something went wrong.
There was a problem hiding this comment.
This should be ...args to match the variable below.
Sorry, something went wrong.
There was a problem hiding this comment.
@apapirovski : my bad.. will fix that !
Sorry, something went wrong.
There was a problem hiding this comment.
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.
Sorry, something went wrong.
There was a problem hiding this comment.
@apapirovski : Please take a look now. Thanks !
Sorry, something went wrong.
|
@apapirovski Yes I also think fn.apply(undefined, args) is best for now. |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM if CI & benchmark CI are happy.
Sorry, something went wrong.
|
CI: https://ci.nodejs.org/job/node-test-pull-request/11915/ |
Sorry, something went wrong.
|
@apapirovski : Thanks much ! |
Sorry, something went wrong.
|
LGTM |
Sorry, something went wrong.
PR-URL: #17486 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benedikt Meurer <benedikt.meurer@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com>
PR-URL: #17486 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benedikt Meurer <benedikt.meurer@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com>
PR-URL: #17486 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benedikt Meurer <benedikt.meurer@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com>
| Back | FazBrowse Home | New Git URL |
Replaced f.apply(undefined, arguments) to ES 6 f(...arguments) Extended Parameter Handling Spread Operator in lib/fs.js
Checklist
Affected core subsystem(s)
fs