-
Notifications
You must be signed in to change notification settings - Fork 215
gh is awful slow at startup: profile & debug #372
Comments
I've done a quick profiling and made the results available @ https://gist.github.com/tomzx/ed21d61eba999245f369. I simply ran I don't have any expertise in using the v8 profiler, but hopefully what I will say is correct. An empty js script takes about 200 ticks to execute while gh with no argument takes 1200 ticks (6x slower).
Based on time, running gh.js is about 400ms of js execution time. On top of that, add about 800ms of wait. Adding a
About half the application time is spent loading the dependencies. I've also dumped a
If I'm not mistaken, it seems to be waiting on a couple of sockets before dying. As you can see, the wait time is around 700ms (while my previous wait time estimate is of 800ms). Thus, if I were to dig in, I'd look for anything that does open up a socket and if there's any way to trim the requires in |
wow! Thanks very much. I am still in the beginning of my learning curve on profiling node apps. A few months ago I have delivered a talk (Writing CLI tools with Node) at my workplace's front-end meetup (Liferay) and such details would add a lot of information to it :) By the way, I have created a small npm tool (require-time) that you can use to tell what dependencies are heavy weight. It's very unscientific, but I found it to be very useful for CLI tools. Watch this require-time screencast to see it. I think the way to go is to load some heavy dependencies just when needed. 3a3c4c4, c088b3e, 5debb99 should be related to this. One of the things I gotta to do is remove the handlebars dependency because it's both heavy and kind of out-of-place (the best template engine for a CLI tool is, well, process.stdout/stderr :)). I am glad @aredridel even used it on the npmjs website tests! henvic/require-time#1 (comment) |
After playing a little bit more, it seems the culprit is the insight package. If I |
@protoEvangelion, it's nice because we can track what is really being used. If you can somehow make it works without adding such delay, then great. Go for it. If you are not able to do so, I am leaving out the removal decision up to you (I don't use gh anymore (I just never remember about its commands and do things on the web interface or manually instead lol), so I don't feel I have a right to say something on this point).� Related: sindresorhus/insight#34 Example of stats we get:
|
Because the app is stable and we have already collected the stats that we needed in order to analyze trends and high demand commands (which by far was After taking out the insight package, it really didn't save as much time as I would have hoped for. BEFORE taking it out, when running AFTER taking it out, that drops to around 45 ms execution time. Since the mind can perceive at least as fast as 13 ms increments, it seems beneficial to remove this package as it will increase the speed of all gh commands, even if it is a very small gain. |
Implemented here: 75d06f6 |
@all-contributors please add tomzx for infra |
I've put up a pull request to add @tomzx! 🎉 |
I'm very unsatisfied by the time gh takes to start up. Compare it with something like git.
Run
git
andgh
, then compare how slower gh is.I believe we can make gh just as fast by using profiling tools to verify what are the bottlenecks and solve them.
The text was updated successfully, but these errors were encountered: