-
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
net: avoid use of arguments
#11411
net: avoid use of arguments
#11411
Conversation
@jasnell I'm confused as to why we're converting over to rest parameters when they're still slower in master? Here is what I get:
Rest parameters are still ~28% slower. When you modify the benchmarks to explicitly specify some of the parameters, the gap closes somewhat, but it's still slower. I think we should revert the recently landed rest parameters usage and give the feature more time for optimization by the V8 team before we start using it in runtime code (tests and such are fine). EDIT: Interestingly, removing the forced optimization (which I think is probably overused in many benchmarks) produces different results, which shows them being much closer in performance. |
@Trott Where did you see that? |
@ronkorving Hrmm... it doesn't show rest parameters and the benchmark site referenced in the article tests rest parameters in a much simpler way (it just accesses one argument and does not make an array of the arguments in the ES5 implementation). Also they're comparing 5.4 and 5.6. I wonder if 5.5 vs 5.6 results in the same increase in performance. This is relevant since IIRC 5.5 will land in node v7.x. |
@mscdex ... I've been benchmarking as I go and what I've found is that the results are fairly inconsistent. We should still avoid rest params in code we know is hot or in cases where there are either no arguments or a fixed number of arguments passed typically. In the case where no arguments are typically passed, the rest params can cause up to a 50% slowdown. That said, in some of the cases where deoptimization is caused either by leaking arguments (by passing it off to an |
@mscdex asked:
@ronkorving replied:
I thought I saw something more recent and more specific about how rest parameters in V8 5.6 would generally be as performant or more performant than |
@Trott Something a bit different, but concerned: https://twitter.com/bmeurer/status/824182909317902336 |
Until we finally turn on Also note that in 5.6 TF lacked quite a few optimizations still for other JavaScript constructs. So while rest parameters are properly optimized, other constructs in the same function might not yet benefit from TF. So my advice would be to wait until we flip |
@bmeurer Ok, so then you are also suggesting we revert recently added rest parameter additions? |
I'd suggest to keep those that fix a concrete problem, like Crankshaft disabling optimization because of funny use of arguments, but wait a bit for the remaining cosmetic fixes. |
I think all of the recent rest params changes have been cosmetic (just replacing a loop). I would rather keep it consistent and avoid potential performance issues by rolling back the rest params changes for now... Thoughts @nodejs/collaborators ? |
👍 from me. |
@ChALkeR The performance is not consistent and the rest params can actually cause regressions as both @jasnell and @bmeurer have pointed out. When I call it cosmetic changes, what I meant was that the use of rest parameters did not happen because we were trying to avoid an existing deopt because of the use of |
My preference in general would be to simply mark those as dont-land in 7 or below and leave them unless they should a definite perf loss. |
@ChALkeR I should notice that #11242 does not use rest parameters, it simply avoids out-of-bounds with |
+1 for dont-land in 7 and lower. This change is definitely valuable only in new V8's, plus also see @mscdex comment:
Also, thanks to everyone in this thread for pointing out this issue. Really interesting conversation for me. |
Rest params clearly got a lot better and this should probably followed up now.
@notarseniy would you be so kind and rebase this? |
Looks like these changes have already happened in 472a665 #13472 Thank you for your contribution @notarseniy ! |
See #11359 and #11358.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
net