-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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: refactor to use rest parameter #35947
Conversation
I remember something like this was proposed a few times but was always rejected due to performance loss. Can you benchmark this? |
Benchmark CI: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/675/console
still too much of a drop to consider using |
I might be reading this wrong, but it seems to be an improvement in some cases. Let me try another approach to get the best of both implementations. CI: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/677/console |
Here are the results:
|
That looks better, but I'm still -1 on this because I don't think it's worthwhile in this case to trade one improvement for a regression in another. If there were reliably no regressions at all, then I would be fine with that. It is interesting that those two different |
Fair enough. Let me try yet another approach that doesn't use the rest operator. Benchmark CI: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/681/console |
|
It seems there might be a sweet-spot. Benchmark CI: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/682/console |
|
Using Array's |
I can see positive improvements, look at line 3 and 5:
and regression at line 8:
It seems to me the improvement outweighs the regression, but maybe I'm reading this wrong. |
I've ran another benchmark CI; some lines look better, probably thanks to #36221, but not all figures are positive still:
|
@mscdex Should I close this? |
Those results look acceptable to me |
lib/timers.js
Outdated
// Extend array dynamically, makes .apply run much faster in v6.0.0 | ||
args[i - 2] = arguments[i]; | ||
} | ||
args = [arg1, arg2, ...arg3]; |
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.
One thing to consider is that this syntax relies on Array.prototype[Symbol.iterator]
and %ArrayIteratorPrototype%.next
, both user-mutable. Maybe it's just a bad idea after all, and we should keep the current implementation.
848fe3e
to
fadc581
Compare
Let's not do that, the current implementation is fine. |
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes