Why is my ember-cli build time so slow on windows?
Asked Answered
S

7

24

Ember-cli is building very slowly with ember server on windows.

Build successful - 13126ms.

Slowest Trees                  | Total
-------------------------------+----------------
TreeMerger (vendor)            | 3154ms
TreeMerger (stylesAndVendor)   | 2051ms
TreeMerger (appAndDependencies) | 1914ms
StaticCompiler                 | 1791ms

This is in contrast to the same project building in less that 1 second on a linux box.

Sinasinai answered 7/7, 2014 at 13:54 Comment(0)
S
17

Official recommendation from ember-cli to improve its performance on windows

Install ember-cli-windows with node using the below command

npm install -g ember-cli-windows

Run the following command on your project root folder

ember-cli-windows

Statics answered 14/3, 2015 at 5:58 Comment(3)
Thanks! I haven't been staying up to date so I didn't know there were tools now for the optimization. Made your answer the accepted answer.Sinasinai
You need to run the command ember-cli-windows as Administrator. Otherwise it is failing with error as Scripts cannot be executed on this system. To fix, please run the command below using PowerShell as Administrator and try again:Serajevo
This script merely reconfigures Windows Defender and Indexing. If you already have those switched off or use other AV or indexing tools (as in my case) this won't help.Uvulitis
S
32

There are two big culprits:

  1. Real time file system scanning or protection
    • Realtime-protection from Windows Defender (also know as Microsoft Security Essentials in win7)
    • Windows Search Indexing
    • Antivirus scanning
  2. Unused files in your bower_components folder

Real time Scanning

During a build numerous files are generate in the ./tmp folder of the ember project, both the indexer and the realtime-protection make additional reads of each file which adds a significant amount of additional file I/O operations.

The fix is to:

This should get your build time down to a couple seconds. Additional speed improvements for Windows are being investigated continuing to be investigated in relation to Broccoli's handling of the build process.

Managing unused bower files

Having lots of files in the bower_components is the biggest culprit.

I wrote up a script, clean-ember-cli.js, that deletes everything but ember-cli dependancies, and anything imported in the Brocfile.js. I'm getting back to around 5 second build times.

Update

Reports are that running console as admin also helps.

Sinasinai answered 7/7, 2014 at 13:54 Comment(18)
Thanks for the suggestion. I saved 8 seconds (out of 17) by adding node.exe and ./tmp to the excluded processes/paths. My laptop is using System Center Enpoint Protection, similar to Windows Defender.Basidiospore
@PedroCheckos glad it was of help! Vote up the question/answer if it was helpful so other can find it.Sinasinai
Hi, I'm having big problems as well (~60 seconds build :/). I changed the windows defender setting on win7 and done the same for avast (even disabled it) but it will be slow all the same. The search index is useless since it's not directly in the user. Help please!Thiol
@Thiol check out my update, there was another question that got a great answer, and I included the script I'm running in my ember app to clean out unneeded files.Sinasinai
I created an empty Ember-CLI project and it takes 7-9 seconds to build on Windows. Even after turning off indexing and Windows Essentials.Underdeveloped
@Underdeveloped That is pretty normal right now. Did you also clean out unnecessary files from the bower_componants folder with the "clean-ember-cli.js" script linked above?Sinasinai
@weston Thanks. Running clean-ember-cli.js helped to get speed near 2s:)Underdeveloped
@Sinasinai I'm new to ember and would like to user your clean_ember-cli.js script. How do I use it for my ember project?Ronda
@nissemand just save the script to the root folder for your ember-cli project and run with node. It should read your Brocfile and exclude any libraries included with app.import(). If you try to build and ember-cli complains about missing dependencies just add to the EMBER_FILES list and do a bower install before re-running the 'clean' script.Sinasinai
@Sinasinai Thanks very much! 155s => 55s (exclude from Windows Defender) => 38s (using your clean_ember-cli.js).Ronda
@Sinasinai I found running the terminal as administrator helped further reduce the build time from 38s to 28s. Apparently this lets ember-clie use symlinks instead of copying files (from this answer). Maybe worth adding to your answer?Ronda
hmm I think my new computer will be a mac!Vinni
Is it just me or is that two culprits, not three?Serial
The third big culprit is you're trying to do it on Windows. Actually it used to say two, I said three after adding the update about bower files but didn't add it the bullet list.Sinasinai
thanks, runing as admin speeds up about 40-50 times, from 90s to 2s :)Cytogenetics
Running node clean_ember-cli.js for me gives "Error: Cannot find module 'glob'"Uvulitis
@GlennLawrence npm install glob --save note that I haven't been maintaining this. It may be deleting new dependencies for ember-cli.Sinasinai
Thanks @Sinasinai but it looks like ember-cli has changed quite a bit. Your script seems to be looking for a Brocfile.js in the top dir but in my ember-cli version (1.13.8) there are a number of Brocfile.js files under the node_modules dir and they seem to be of a different form expected by the script, i.e. no reference to "bower_components".Uvulitis
S
17

Official recommendation from ember-cli to improve its performance on windows

Install ember-cli-windows with node using the below command

npm install -g ember-cli-windows

Run the following command on your project root folder

ember-cli-windows

Statics answered 14/3, 2015 at 5:58 Comment(3)
Thanks! I haven't been staying up to date so I didn't know there were tools now for the optimization. Made your answer the accepted answer.Sinasinai
You need to run the command ember-cli-windows as Administrator. Otherwise it is failing with error as Scripts cannot be executed on this system. To fix, please run the command below using PowerShell as Administrator and try again:Serajevo
This script merely reconfigures Windows Defender and Indexing. If you already have those switched off or use other AV or indexing tools (as in my case) this won't help.Uvulitis
O
2

mind one important thing... and I didn`t found out in any forum... if you are working with a laptop and you are not connected with AC, windows may run in low performance mode to keep battery. This cause ember build proyects 4 times slower

Otiliaotina answered 29/6, 2015 at 13:21 Comment(1)
This is true of any processor intensive task.Sinasinai
R
1

Using ember-cli 1.13.13 with a command prompt running as an administrator fixed it for me

Rapp answered 13/12, 2015 at 17:52 Comment(0)
J
1

In addition to answers provided above run

ember s

in powershell in admin mode. This enables symlinks which are not enabled by default in windows. Having symlinks creates a flatter node_modules folder which results in faster running times.

(Source)

Jarib answered 18/12, 2017 at 1:18 Comment(0)
G
1

From build 20262 Windows 10 have WSL 2. This is Linux on your machine and gives us performance as good as on Linux.

Get last Ubuntu from Microsoft store.

Do not use /mnt/ folder for repo because of slow speed, use ~ folder.

Connect with terminal on Ubuntu and clone your repository.

    cd ~
    git clone your-repo

install node version manager and node

Install ember-cli and start server.

    npm install -g ember-cli
    cd ~/your-repo
    npm i
    ember serve

In VSCode install plugin "Remote - WSL", open your repo and start development.

Gratification answered 4/3, 2021 at 19:2 Comment(0)
U
-1

With Windows 7 I got a 50% improvement by turning off Encrypting File System (EFS) for the project's /tmp directory. (right-click Properties->Advanced->Encrypt contents...)

For later versions of Ember CLI running in admin mode as mentioned here and suggested by D-Go in his answer seems to be the way to go, assuming your company allows this.

If like me you are using GIT Bash to run Ember you may be interested in how to set it up to automatically run in admin mode here

Uvulitis answered 22/10, 2015 at 0:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.