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: Details |
|
@mscdex Should I close this? |
|
Those results look acceptable to me |
lib/timers.js
Outdated
There was a problem hiding this comment.
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