-
Notifications
You must be signed in to change notification settings - Fork 12k
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
Build with "ng -prod" is extremely slow #6795
Comments
@filipesilva Is this the expected behavior, do i need to change something ? |
Production builds are usually slower than development builds. Besides using I do think your build time is too long though. I haven't seen other apps that have such a big difference between prod and dev build time. I'm unsure of what's happening. Perhaps it's related to webpack/webpack#4863. Is this a public project that I can look at? You might also have a cyclic dependency perhaps.. if so, #6813 could help you. Note: sourcemaps are disabled in production builds by default, while css extraction is enabled by default. |
Same problem here
@filipesilva you can check here if you can see import problem : https://plnkr.co/edit/xMf8HXoNIhq3urJ6cPXQ?p=preview This is one proble "slow" but Other problem is : I don't understand why on dev mode "ng serve" after cli recompile fils changes and finish the browser autorefresh and I need wait 6-7seconds until browser finish refreshing this is very very big and make me crazy |
@filipesilva how is Angular-cli tested with real life projects? 20-50 modules and 5-10 thirdpary JS Libs? |
Same issue here:
|
FYI, it speeds up considerably when I leave off the --sourcemaps option. Off course, that's a must have so it still needs a fix......
|
Anything on this @filipesilva? We are running
|
Any update on this? We're even to the point where we're seeing JavaScript heap errors when we compile with sourcemaps turned on. |
Angular CLI: 1.5.2 @angular/cdk: 5.0.0-rc0 |
|
Angular 5 Time: 413322ms |
Production builds will always take longer than dev builds though. There's multiple optimization passes that take a long time to provide with smaller bundles. |
After upgrading to 1.6.0 I went from ~55 secs to ~45 secs for a small project, without css processing. It seems there is an improvement. I don't dare to say it's too significant, but it's a step in the right direction. Btw, is there a recommended upgrade path? I just updated package.json, removed node_modules and package-lock.json and npm installed everything from scratch: without a clean and reinstall nothing would work. |
@filipesilva no luck time: 167712ms .. ng build --prod @angular/cli: 1.6.0 |
Same issue Production Build taking too long to finish |
Same issue here:
|
For me it used to be ~30mins now its ~1h 20mins |
Same here, taken 160s before, now it takes 390s with these params: |
That's definitely a long time. Does it get smaller if you pass |
@rezonjov @ScottSpittle @dprandzioch are you using Angular 5.x? |
Partial relief with --build-optimizer=false and cli 1.6 Date: 2017-12-11T16:38:33.792Z |
@filipesilva Angular 5.1.0 and CLI 1.6 |
@jpsk Thank you for your solution in #6795 (comment) The fix was to use In my case I had a build time from |
It's very strange for me - i have had 11 minute builds for the last month.. but 2 days ago i had some 40 second builds, and now back to 11 minute builds. I didn't change many things - so no idea how i got he 40 second builds.. |
All of the OSX developers on our team were experiencing very high CPU usage, and very slow |
as by reading all the comments and seeing my own angular 6 build time, I'm concluding that UglifyJSPlugin at 92% is taking most of the time and RAM as well, it is consuming more that 2GB of RAM for just one build. |
Saved my day @kellycrowther . Thanks, m8. I confirm that on os x with nodejs v10.11.0 I can see a significant improvement |
same issue :( Date: 2018-10-15T09:17:21.275Z |
Same issue on OS X, |
Our build with these parameters (ng build --prod --aot=false --optimization=true --sourceMap=false --buildOptimizer=false) creates 71 bundles in just over 2 minutes with a total size of 11MB for all bundles. Now we turn the --aot flag to true and what happens?? The build takes about 43 minutes, comes up with 84 bundles and has a total size of 22MB???? Isn't AOT supposed to minimize the size by excluding what is not being used? But instead it takes 41 minutes to create twice as many code? What's going on here? |
nope, aot is about pre-compiling your templates and boosting up app/modules startup by removing runtime compiler and runtime compilation phase |
@artaommahe that's probably what I meant. ;-) But to be honest, I have the experience that the --aot=false version is actually starting up faster.. Not very strange I think if you compare the total size of the bundles… @filipesilva unfortunately it is not :-( But all packages are up-to-date. I've attached the build outcomes. You need anything else? Angular.json? Package.json? |
@negberts aot precompiles the HTML templates into straight forward js files which keep the view updated. These are larger than the templates themselves, so there's a point where the combined size surpasses the size of the runtime compiler. But you pointed out the bundles are so much bigger you consider the non-aot is faster to startup. Which may be true for uncached assets, plus the difference in parsing a larger file. I build into a single bundle, so your experience with so many bundles ought to be different. I suggest you compare these options on different devices as well. Mobile and desktop, and keep the one that perform better. |
Since recent versions I can't use appveyor CI no more since the build runs more than an hour. |
@HarelM 2 things you could try that seemed to help me. Upgrade You're also mixing scss and css. Which doesn't seem like it would be a big deal, but when I converted all my css files over to scss, I saw my build time drop quite a bit. I just tried it out on your repo and didn't see much change, but the build only took a little over a minute for me. |
@hahn-kev Thanks for the super quick response!
Did you build it with |
@HarelM Yeah I did build it with Oh ok, yeah I didn't build the openlayers branch. But I had really slow build times when using source maps when I had scss and css. But it doesn't look like you have source maps on, so maybe you're hitting a different issue? |
I now see that the debug builds when using the |
TL;DR: use |
@thenslerse, sorry to necro-tag you here, but were you by chance using semantic-ui in this project? I get the exact same two warnings in my app.
|
angular universal is too slow to build, takes more than 20-30 mins to build and its not smooth to build and release. cant it be simplified ? I do the client build , then it does a server build, then again it will do a webpack to package a server.js which goes with all plugins that we add up , close to 24-30 mb single file. definitely needs a simplified way or fast build flow. |
@Brandon-Born Thank you!!! |
I cannot even compile a small boilerplate-based project (angular-material, a 2-3 dozen very small modules, <5k LoC total) on a 1gb ram EC2 instance, even with every possible memory intensive option disabled:
Even with all these flags disabled, on my local machine this takes about 1.2gb of ram and about 30 second to build on an i7 based machine. Unacceptable. |
@skylarmb Unacceptable by who? Depending upon which absolute standard? The build of Javascript applications is complex. 1GB RAM is absolutely nothing. You should expect to have build occupy a lot of resources. The issue is time, not RAM usage. 30 seconds to build, considering you are starting at least 4 processors (tsc, sass, the whole npm thing, Uglify, WebPack, and who knows what else), is perfectly acceptable if there is a way to keep the development build shorter (which usually is the case). With JS, you are exchanging resources for flexibility and convenience. If you want to use less RAM, use GoLang. ;) |
@alberto-chiesa (trolling accepted :-)) Whilst there are no real benchmarks for such processing from the angular team, we can clearly see severe regression whilst compiling. An angular 7 project with a similar amount of files to a Angular 5 one takes 5x as long here on our development environments. It should also be noted that this is after memory and other optimizations, without those it was taking nearly 8x as long. We've gone backwards here. |
@inthegarage I'm not saying that there are no problems. I'm following this thread from the very beginning. I'm just saying that considering unacceptable that the Angular build requires more than 1 GB of RAM is naive. The issue is time: if the build is 5x slower, it's a problem (a huge one). But, if I can get the same build time throwing in more RAM, it becomes less of a problem. |
@alberto-chiesa Agreed, there are some naive assumptions and when an IDE can gamefully hog 3GB+, to expect a compiler to use anything less is not realistic. All points clarified. |
Hi all, After upgrade all the dependencies our compilations times are significantly increased, from ~2min to more than 25min (we have not waited so long). Checking which dependency have the problem, we found the last version of Terser. We solve the problem fixing it to the 3.8.1. |
Hey all, There were two performance regressions recently that affected 7.x. The first was in CLI 7.0 was affected by #12646, fixed by angular/angular#26734 and microsoft/TypeScript#28028. Using at least CLI 7.1 was affected by #13102, which will be fixed by #13309, and should be out in next patch versions of the CLI build system ( I think that in the past having this single issue for all performance related problems was useful, but it's not as useful anymore. More than a year has passed with a lot of new versions of Angular CLI in between then and now. During that time a number of performance regressions came up, were fixed, and new ones came up. Having all the feedback in a single thread makes it hard to get meaningful reports, or to inform people of what versions the regressions that affect them were fixed. At the time of writing this comment, there are 116 hidden comments: Having so many hidden comments makes it hard for people to find information in anything but the latest comments. But on the other hand I don't think most people would go through all of the comments anyway. New users that see this thread mostly read the first and latest comments and lose things said in between. So instead of having this mega-issue, we'll try to have current high impact performance issues pinned at the top of the issue tracker: Generally speaking, if you are using the latest version of the CLI build system (that's Another thing to keep in mind is memory usage, which has a similar issue in #5618. Bigger projects take more memory to build, and when you are close to the memory limit performance may suffer. Please bear in mind that project size is not only your source code, but also includes all of the libraries you use. Please check my comment in #5618 (comment) to see how you can increase the memory limit. So for the reasons stated above (high volume of comments, hidden comments, hard to report and inform people) I'm also locking this issue to prevent this comment from being lost as new comments come in. Thank you to everyone that reported and helped diagnose these performance problem. If you encounter any new ones, please open a new issue so we can give that specific regression our full attention and provide a resolution for it. |
Bug Report or Feature Request (mark with an
x
)Versions.
ng --version
_ _ ____ _ ___
/ \ _ __ __ _ _ | | __ _ _ __ / | | | |
/ △ \ | ' \ / _
| | | | |/ _
| '| | | | | | |/ ___ | | | | (| | || | | (| | | | || | | |
// __| ||_, |_,||_,|| _|||
|___/
@angular/cli: 1.1.0
node: 7.9.0
os: win32 x64 (Win 10 Enterpirise - 16Gig , i7)
@angular/animations: 4.0.0
@angular/common: 4.0.0
@angular/compiler: 4.0.0
@angular/core: 4.0.0
@angular/forms: 4.0.0
@angular/http: 4.0.0
@angular/platform-browser: 4.0.0
@angular/platform-browser-dynamic: 4.0.0
@angular/router: 4.0.0
@angular/cli: 1.1.0
@angular/compiler-cli: 4.0.0
@angular/language-service: 4.0.0
Repro steps.
$ ng build --prod --aot=false -ec --sourcemap=false
Hash: 552d9867ececa788ac3a
Time: 670222ms
chunk {0} polyfills.d77767cee98c83f90386.bundle.js (polyfills) 294 kB {5} [initial] [rendered]
chunk {1} main.255e1d27fe4d40b56ab2.bundle.js (main) 1.51 MB {4} [initial] [rendered]
chunk {2} scripts.45a4574f31d7b91e5a5e.bundle.js (scripts) 3.88 MB {5} [initial] [rendered]
chunk {3} styles.ac17d766c993c4027892.bundle.css (styles) 228 bytes {5} [initial] [rendered]
chunk {4} vendor.86c029ec4598fb674488.bundle.js (vendor) 8.23 MB [initial] [rendered]
chunk {5} inline.750f0337ff0a9bee9813.bundle.js (inline) 0 bytes [entry] [rendered]
ng build --aot -ec -sm
Hash: 24f744145f250126e699
Time: 62809ms
chunk {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 294 kB {5} [initial] [rendered]
chunk {1} main.bundle.js, main.bundle.js.map (main) 3.07 MB {4} [initial] [rendered]
chunk {2} scripts.bundle.js, scripts.bundle.js.map (scripts) 3.88 MB {5} [initial] [rendered]
chunk {3} styles.bundle.css, styles.bundle.css.map (styles) 228 bytes {5} [initial] [rendered]
chunk {4} vendor.bundle.js, vendor.bundle.js.map (vendor) 7.37 MB [initial] [rendered]
chunk {5} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]
670222ms vs 62809ms is a huge difference
The log given by the failure.
There is no failure , the build takes a very long time to complete its stuck at
92% chunk asset optimization
and then we have to wait for 10-15 mins to get the build completed.I have disabled aot and sourcemaps, still the speed is very slow.
Desired functionality.
build should have similar time that to of
ng build -aot
Any help and guidance to reduce will be helpful.
The text was updated successfully, but these errors were encountered: