-
Notifications
You must be signed in to change notification settings - Fork 2.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
NPM Install Speed #553
Comments
We are considering installing npm read through caching servers in the hosted build pool. I assume you are referencing hosted build (and not your own agent). The other immediate way to speed up npm step considerably is to install your own agent on an azure VM ( http://aka.ms/tfbuild ) - that's a persistent agent so you get incremental. modules would be there from build to build and would only pull new one when you use a new one/version. |
Cheers Bryan, i'm actually On Premise here. Are you basically referring to not doing a clean build when you refer to incremental modules? I'm not a huge fan of moving away from clean builds as i've had problems in the past with lingering modules masking errors. There's also the problem of artifacts lingering between builds. Have you got a solution worked for these without writing custom steps to clean up folders? |
Well, we're just calling npm so it's between your box, your network and the npm services. That said, there is a solution. You can install a read through npm cache. That will allow you to do clean builds and still get fast npm installs. Something like this is what we were looking at for our hosted pool: https://www.npmjs.com/package/sinopia You could install it right on the agent or on another box local to your network. You would point your npm config on the agent at that read through cache server. |
Cheers Bryan ! |
I also just found this which will be simpler and alleviate the problem with an on prem agent: |
Cheers again Bryan, i did have a go with Sinopia but had some trouble getting it working reliably. Their documentation for installing as a windows service was a bit date also. Will give npm-cache a go! |
FYI Bryan. I had a look at npm-cache - It looks great but it's not a viable option on windows boxes for now. Apparently it's getting worked on though! |
Again - FYI. I've ended up using Sinopia as we wanted to start hosting internal NPM packages. It's taken a 14 min build down to around 11 minutes. |
Awesome |
+1 for caching npm modules on hosted build agents. Services like codeship do this and it makes the whole experience more fun :) |
@bryanmacfarlane did you finalize the consideration? This issue was closed without any feedback regarding this. My npm install of a react boilerplate js application takes about four minutes on the hosted build agent :( |
assigning to zack for thoughts. Last time we looked at the bottleneck, npm local I/O (updating local cache folders) was dominating the time on hosted agents. Since then though, we've sped up I/O with D2+SSD. In addition, resolving the graph of versions might also dominate the time before it ever gets to pulling them from the cache server. So, it's unclear whether it would help much on perf. Zack drives the packaging team so he can talk to it. |
@zjrunner for what it's worth, here my (shortened) log. And yes, @bryanmacfarlane might be right with his thoughts about the domination of graph resolution...
... skipping ~1500 lines of an impressive npm module graph ...
|
We're just getting into the npm build-task space on my team so we have a bit of ramping up to do on costs and complications to optimize away some of the common pain points. One point I'd make about a comment earlier in this thread -- there was a question about custom agents and losing clean builds. From what I've seen your npm cache is maintained in the user profile so you can still do your clean builds and they basically come down to local unpack/copy (so you get to re-layout and stay clean). %appdata%\npm-cache on a windows machine. If the network was your issue that would be closer than a remote cache. If the module graph is your problem, probably not a lot of help. We've begun looking into yarn as well, not sure if it makes any optimizations here or this is purely a function of the number of tiny files to move around on disk. |
I have seen in the past about the progress display severely affecting performance. Is this also the case with Seems like |
We are also looking into speeding this up on hosted VSTS agent. Using an internal cache sounds like a good idea. |
Please! Heroku Speeds should be your target. They are orders of magnitude faster. |
There is a suggestion on user voice to use a cache to improve install time |
The fastest implementation would be to reuse the resulting node_modules directory from a previous build if package.json has not changed (like commonly done using Docker). This is a much needed improvement! |
I'd have to disagree @teemuy. That'd have to go on the assumption there's no min/major version matching going on. I find the majority of problems i get from Node based builds is minor increments breaking the codebase when they shouldn't! |
I'm not sure what you are disagreeing about. My comment was about maximizing install performance, which is a pain point in our system where the install takes several minutes in each build. |
Abandoning builds on Azure for NPM projects was the way to go for me! |
@zjrunner yarn definitely made a difference for us - I'd recommend using a linux agent though |
We also had success with using a yarn offline mirror committed to the VCS, using the |
Improving the speed would be a great plus for many. Right now for a simple solution it takes 3 minutes alone to install all the npm dependencies. I wonder if using https://www.visualstudio.com/da-dk/docs/package/overview has any impact in the performance? |
@Saturate Probably not a big help, unless you have slow network and have disabled caching. For us it's the npm install processing that takes time. We are using a local npm repository (Artifactory) but still our local vsts takes minutes to run the npm install stage at the start of each build. |
@RDalziel, |
Reading back i mentioned installs taking around 10-15 minutes. These days - it's around 2-4 minutes so i really haven't felt the need to improve on this further. Fairly happy with that speed at the moment. Although - SPA builds do generally feel like they take much longer than .NET builds - but i doubt that'll ever change due to the much larger number of files that are transferred during NPM Installs in relation to NuGet Restores |
@RDalziel , |
Hello, any update on changes in this area? This task alone accounts for ~80% of our build time, across several web sites using hosted VSTS agents. Typically our builds take between 8 and 10 minutes (different sites), so it's a substantial amount of time for CI builds :( |
@jimmyheaddon, Are you certain that one of your packages isn't doing something long-running in post-install script. Have you tried 'npm install --ignore-scripts". |
Some more detail would have been helpful yes, sorry @keithrob! We're using the latest LTS versions of Node and npm (6.11.4 (includes npm 3.10.10)), so that might explain a few things. We're hosting our own npm packages using the VSTS package manager, so potentially that proxying behaviour is to blame, too? I've given I'll try a new version of npm to see if that helps, but we're a bit stuck with the LTS version :( Thanks! |
@jimmyheaddon, |
@keithrob that's worked brilliantly! We now install the current release of Node, run |
So Azure will or not fix this problem? |
|
Hi folks - we are actively looking into the caching issue and hope to start work first up in the new year. Package restore scenarios is right up there (probably #1) scenario that we want to solve for. |
I guess this is the ticket we can follow right https://developercommunity.visualstudio.com/idea/365799/improve-hosted-build-agent-performance-with-build.html?utm_source=t.co&utm_medium=referral |
Is there any way with the current build task to increase the speed of NPM installs?
I've seen methods of caching being referenced around the web, but unsure that's possible with the current NPM Build Task setup.
NPM installs are usually the main cause of slow builds on front-end builds at the moment, any way of speeding them up would be a great boost!
The text was updated successfully, but these errors were encountered: