-
-
Notifications
You must be signed in to change notification settings - Fork 939
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
The merge
function is slow
#1016
Comments
Are there any other heavy places like |
Here's a more detailed tree where we can see what the code does when we invoke got: This comes from a 70 second profiling. There are more places where we call got with a different option object each time as we are performing POST json requests. It seems the |
@sindresorhus You need to see this: |
@szmarczak Micro-benchmarks are pretty useless without context. If you run Got seven million times in real-world situations, the network is going to be the bottleneck, not a simple loop. |
@cesarfd What Node.js version and OS? |
I think it depends if you're running a very very very low-spec machine / VPS and make thousands of requests... |
@sindresorhus Also shouldn't we deep clone arrays too? For example you can do: got.extend({hooks: {beforeRequest}});
beforeRequest.push(fn); and the instance will be affected. I think it's a regression. |
@cesarfd Could you also provide performance profiling for |
Node 12.13.1 under a buster-slim docker image + Linux AMI |
Yes, I'll rerun the profiler on Monday. |
@szmarczak |
Thank you very much, if you provide also profiling for |
Sure. My point was that standalone micro-benchmarks doesn't mean anything without the context. It's better to profile the actual running code on the actual system. |
Yes |
I also noticed that got can be "relatively slow" to create an instance, If you have any improvements I'm interested to try them :) In my case the request is done on localhost so the network is fast. |
@cesarfd What tool do you use to display the performance timings? Could you tell me how to enable it please? That'd be very useful. |
@szmarczak It's all in the chrome inspect tool. basically the procedure is as follows:
https://nodejs.org/en/docs/guides/debugging-getting-started/ |
@cesarfd I already know that, I thought you were running a fork of Chrome Dev Tools because I can't find anywhere the option to enable the timings in the Source tab... |
@cesarfd Friendly ping :) |
Oh, right, just click on the source code file, where it says the file name
and number, it will take you there.
El sáb., 1 feb. 2020 17:15, Szymon Marczak <[email protected]>
escribió:
… I meant this, not the flamegraph (sorry if I got you confused):
[image: image]
<https://user-images.githubusercontent.com/36894700/73595229-79021c80-4516-11ea-8207-0ac3522626e2.png>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1016?email_source=notifications&email_token=ACTTGMVSISWWWPKEJWK7B6LRAWN37A5CNFSM4KEJVIZ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKRAUMQ#issuecomment-581044786>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACTTGMQMVRSFWYYADH6LFE3RAWN37ANCNFSM4KEJVIZQ>
.
|
Hmm... It takes me there but there are no timings... Will try a different Chromium browser. |
@cesarfd Oh, I've got it now! The running node script must not exit in order to display the timings (at least in my case I think). Thank you :) |
Maybe Sindre should consider removing comments as an optimization. 😛 |
What would you like to discuss?
Hi, we are using got heavily in my company to send several thousand requests/s so I'm doing some profiling to see in which places our app spends its time the most.
I've recently upgraded to Got 10 and I've seen that the library spends a significant (though, not alarming) percentage of the time in the normalize arguments phase, which at the same time calls the aforementioned merge function.
It looks like this single
slice
call to clone the array seems to spend quite a lot of time. So, my question is, do we really need to clone the array or could it be just referenced? If we need a copy, isslice()
the fastest method?I tried https://jsperf.com/cloning-arrays/3 in Chrome 79 and it seems that there're faster (not so much tbh) alternatives.
Checklist
The text was updated successfully, but these errors were encountered: