-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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: use rest parameters in nextTick. #12183
Conversation
This increases the performance of stream/writeable-manywrites.js both with Crankshaft and with Turbofan significantly.
Individual scores of |
if (typeof callback !== 'function') | ||
throw new TypeError('callback is not a function'); | ||
// on the way out, don't bother. it won't get fired anyway. | ||
if (process._exiting) | ||
return; | ||
|
||
var 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.
There is a minor difference now when arguments.length === 1
as args
is an empty array instead of undefined
. I don't know if it's relevant. If not LGTM.
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.
Good point. Fixed the use site. It doesn't seem to affect performance though.
I'm assuming this is V8 5.7 only. |
Also, is there still a performance regression when the rest parameters only constitutes one argument (e.g. |
At least with a micro-benchmark rest parameters do not seem to be slower than arguments object:
I get with the current master:
|
FWIW I get much closer results when bypassing the loop in arguments-1 318 |
I think the empty array creation was avoided because it was unnecessary. Although, I'm not sure how that optimization vs. having a consistent value type for |
From what I've seen in my own benchmarking, V8 5.8 and higher does not seem to have the same performance regression for rest params < 2 arguments. There's still a bit of a hit but it's not as bad. Hopefully it will continue to get better. |
In general I'm happy with the change and it's definitely the right direction, we just need to be careful not to introduce regressions in the most common cases in hot code paths. We also need to be cognizant that these kinds of changes will make backporting to LTS far more difficult. That all said, this change LGTM |
I'm hesitant to make this change unless we are very sure. Experimenting with |
I created this change because this fixes a performance regression with stream/writeable-manywrites.js with V8 5.9, with the new compilation pipeline. I'd be happy to wait with this PR until then, or run additional benchmarks, should that be required. |
Let's hold off on landing until after 8.0.0 is released and we update master to 5.8. There will be a large number of these kinds of changes that need to happen to avoid regressions under 5.9, we'll want to be coordinated and deliberate about making them since there will be a definite impact on our ability to easily backport changes to LTS. |
@hashseed Would you be willing to re-open this? It's still something we want, right? |
FWIW I started working on a version of this yesterday, with a few other changes. Still testing performance to find the optimal one. @hashseed if you prefer to resume this work let me know and I'll stop working on mine. :) |
@apapirovski I do not mind if someone takes this over :) |
This increases the performance of stream/writeable-manywrites.js
both with Crankshaft and with Turbofan significantly.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
process