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.

Weston
  • 2,732
  • 1
  • 28
  • 34

7 Answers7

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.

Community
  • 1
  • 1
Weston
  • 2,732
  • 1
  • 28
  • 34
  • 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. – Pedro Jul 14 '14 at 01:16
  • @PedroCheckos glad it was of help! Vote up the question/answer if it was helpful so other can find it. – Weston Jul 14 '14 at 01:50
  • 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! – Vinz243 Sep 14 '14 at 12:23
  • @Vinz243 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. – Weston Oct 07 '14 at 05:11
  • 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. – jaaksarv Dec 01 '14 at 17:14
  • 1
    @jaaksarv 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? – Weston Dec 03 '14 at 17:47
  • @weston Thanks. Running clean-ember-cli.js helped to get speed near 2s:) – jaaksarv Dec 03 '14 at 21:47
  • @Weston 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? – Felix Feb 10 '15 at 23:06
  • 1
    @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. – Weston Feb 11 '15 at 01:40
  • @Weston Thanks very much! 155s => 55s (exclude from Windows Defender) => 38s (using your clean_ember-cli.js). – Felix Feb 11 '15 at 08:39
  • 3
    @Weston 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](http://stackoverflow.com/a/27610912/1438809)). Maybe worth adding to your answer? – Felix Feb 18 '15 at 23:34
  • 3
    hmm I think my new computer will be a mac! – SuperUberDuper Apr 01 '15 at 11:27
  • Is it just me or is that *two* culprits, not three? – Marco Prins Jul 16 '15 at 08:07
  • 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. – Weston Jul 20 '15 at 20:03
  • 1
    thanks, runing as admin speeds up about 40-50 times, from 90s to 2s :) – Stefan Kostic Oct 01 '15 at 12:50
  • 1
    Running `node clean_ember-cli.js` for me gives "Error: Cannot find module 'glob'" – Glenn Lawrence Oct 22 '15 at 00:48
  • @GlennLawrence `npm install glob --save` note that I haven't been maintaining this. It may be deleting new dependencies for ember-cli. – Weston Oct 22 '15 at 18:37
  • Thanks @Weston 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". – Glenn Lawrence Oct 22 '15 at 22:35
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

Weston
  • 2,732
  • 1
  • 28
  • 34
Vinoth Kumar
  • 1,347
  • 1
  • 14
  • 23
  • 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. – Weston Mar 14 '15 at 21:46
  • 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:```` – divinedragon Oct 08 '15 at 10:02
  • 1
    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. – Glenn Lawrence Oct 22 '15 at 00:45
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

ivanchuk
  • 21
  • 1
1

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

D-Go
  • 413
  • 5
  • 9
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)

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
krtkgpt
  • 46
  • 1
  • 4
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.

Ramil Gilfanov
  • 552
  • 1
  • 8
  • 12
-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

Community
  • 1
  • 1
Glenn Lawrence
  • 2,844
  • 1
  • 32
  • 38