-
Notifications
You must be signed in to change notification settings - Fork 30k
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: attach listOnTimeout function to TimerWrap #18388
Conversation
d7de270
to
1c7472b
Compare
This was done at JsConf.Asia at the code in the dark even with @lrlna. |
@bmeurer what do you think? |
I just ran But the performance indeed seems to have improved. I think this is not due to deopts, but rather due to inlining. I ran the same benchmark with and without the patch like this:
And diff'ed the output:
|
I would suggest to only make this change if it semantically makes sense to. It does from what I can tell. If you are only making this change to improve performance, I'd wait until we have figured out whether we can improve that in V8. |
Also filed V8 bug here. |
@hashseed I can reproduce the problem on Node 8, which has the same line ( Line 197 in 96e8250
I'll update the description and the comment to note that it is related to inlining rather than deopts. |
1c7472b
to
0b80ccc
Compare
What I'm saying is that this is an observable change. If this is fine from a semantic point of view, fine. If that's not intended, but only to reap performance benefits, it might be better to wait for V8 to fix this? |
This is fine from a semantic point of view, but I would not have touched this if it wasn't for the performance benefits. I do not think we could backport the future version of V8 that would have a fix for this in Node 8 - and it would be handy to land this patch there sooner rather than later. I think fixing it in V8 would be great, as this is a pattern that I have seen several times. |
It's fine semantically.
Ok so, this is not 100% true. Your results say this:
Those are unpooled timers that benefit from this. Unpooled timers almost never exist in the wild like this. No one (to my best understanding) continuously schedules timers with unique durations. So really, It's hard to be convinced that inlining is the issue here either - perhaps it's more like an initial bind kind of thing. This function should be called just as much for the pooled benchmarks as the unpooled benchmarks afaik. (Not that I know more about @hashseed about this, lol) tl;dr the perf benefit is likely next to none in any reality unfortunately |
Make the listOnTimeout function inline by attaching it to the TimeWrap prototype. It improves insertion and cancellation time of unpooled timers by 18% and 28% respectively.
0b80ccc
to
2c0fcbc
Compare
Yes and no. This came out from testing an HTTP route when adding some delay, and it yielded a nice 10% throughput increase. However, I agree this is a case that very seldomly applies to real world applications and more with synthethic benchmarks. I've updated the commit message and the PR description. |
Landed as eb34278. |
Make the listOnTimeout function inline by attaching it to the TimeWrap prototype. It improves insertion and cancellation time of unpooled timers by 18% and 28% respectively. PR-URL: #18388 Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Jon Moss <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Weijia Wang <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]>
Make the listOnTimeout function inline by attaching it to the TimeWrap prototype. It improves insertion and cancellation time of unpooled timers by 18% and 28% respectively. PR-URL: #18388 Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Jon Moss <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Weijia Wang <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]>
Make the listOnTimeout function inline by attaching it to the TimeWrap prototype. It improves insertion and cancellation time of unpooled timers by 18% and 28% respectively. PR-URL: nodejs#18388 Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Jon Moss <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Weijia Wang <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]>
Should this be backported to |
This avoid continuous deoptimizations cycles in V8 for the listOnTimeout function by attaching it to the TimeWrap prototype.
It improves insertion and cancellation time of unpooled timers by 18% and 28% respectively.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
timers