-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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: small nextTick cleanup, including removing manual args copying #19153
Conversation
Instead of manually copying the arguments into a new Array, use rest syntax to gather up the arguments as it's actually more performant starting with V8 6.4.
As of V8 6.4 it appears to no longer be necessary to preset the callback on TickObject to null to avoid hidden class function tracking. The benchmark perf is now equivalent regardless.
Mostly what I expected from the benchmark (depth.js & exec-args.js regressions, improvements to breadth-args.js and depth-args.js), although very different result for
Here's my local run for
|
Benchmark CI for streams: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/133/ |
If you have uses of the rest parameters object that are not |
No clue what's going on with the perf differences on my Mac vs the benchmark CI:
My system:
Having a quick look at the raw data, it seems like the benchmark CI results have a much wider spread (lots of outliers) vs my local results which are always roughly the same for each run with very few outliers. Perhaps some GC differences or something? |
I removed the |
@nodejs/process @nodejs/timers PTAL |
Can you run the benchmarks again with @bmeurer's suggestion? The code changes LGTM but I trust the CI's benchmarks. |
@benjamingr i don't think there's an applicable suggestion here. It was a response to a question I had deleted. I need to run a benchmark against v8 6.5 now. |
Ping @apapirovski |
Won't have time to look at this for a while but the rest param performance profile when storing the resulting array is a bit sketchy at the moment. The benchmarks seem mostly fine for |
@apapirovski yes, I fear that a couple of our benchmarks do not yield the results that we expect. If I find the time, I will have a look at some to try to improve them. |
@BridgeAR I think there's also probably more to it that can't easily be tested using micro benchmarks. I know streams use nextTick extensively so I might try testing this against those sometime. It's a bit closer to real usage at least. |
A couple of small changes to nextTick, mostly dependant on V8 6.4+ so we shouldn't back-port these.
Instead of manually copying the arguments into a new Array, use rest syntax to gather up the arguments as it's actually more performant starting with V8 6.4.
As of V8 6.4 it appears to no longer be necessary to preset the callback on TickObject to null to avoid hidden class function tracking. The benchmark perf is now equivalent regardless. (Edit: this doesn't seem to apply universally so it's possible the reasoning here is different. In Timers, I'm still unable to get rid of similar code without tanking the performance 3x. Strangely we have a similar benchmark for both timers & nextTick but clearly something else is going on...)
This is a temporary commit that introduces the 1st change to internalNextTick but will be made redundant once async_hooks,process: remove internalNextTick #19147 lands.
There's a performance benefit to this change on most of our nextTick benchmarks except for two but the regression there is smaller than the overall gains. It also slightly improves some of the streams benchmarks which should be more representative of real usage.Edit: see below for more info.Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes