My Ember CLI project is currently taking 8-9 seconds to build, and I'd like to understand why. The project is not that large (~180 files under app/
including hbs and scss).
Here's my brocfile: https://gist.github.com/samselikoff/874c90758bb2ce0bb210
However, even if I comment my entire Brocfile out and export just the app
variable, the build still takes 5-6 seconds.
I'm not quite sure how debug. Here's my slowest tree logs:
Build successful - 8874ms.
Slowest Trees | Total
-------------------------------+----------------
TreeMerger (appAndDependencies)| 1286ms
TreeMerger (vendor) | 1275ms
CompassCompiler | 1204ms
StaticCompiler | 1185ms
TreeMerger (stylesAndVendor) | 1151ms
TreeMerger (allTrees) | 706ms
StaticCompiler | 625ms
In addition to @tstirrat's answer:
Only running as administrator will allow You to use symlinks files (Default
SeCreateSymbolicLinkPrivilege
flag) try running cmd (or PowerShell) as administrator and see if it helps.You can allow it for specific user using
Local Policies
configuration.Answer taken from here
UPDATE: If you are using
ember-cli
version 0.1.0 or newer, this hack is probably not necessary.ember-cli
now symlinks files instead of copying. You may still get a performance improvement on windows or slow disks.Broccoli (used by
ember-cli
) stores its temporary state in the file system, thus it's very file I/O dependent. Try to reduce the number of files in yourpublic/
,vendor/
andbower_components/
directories. All files inside these folders will be copied at least once per rebuild cycle. The size and number of files in the folders affects performance greatly.Essentially, every time you change a file, broccoli is copying files between the many directories inside
<ember app>/tmp/
. In the case of yourbower_components/
dir, it appears to be copying every single file more than once. It needs to do this because you might useapp.import('some.js')
in yourBrocfile.js
, you might also@import "some.scss"
in SASS/LESS files. There is no way to know which files you actually need, so it copies all of them.If you remove the files that you do not need from
bower_components/
andvendor/
, you will notice better build times.A real world example
If you install the
highcharts.com#3.0.5
bower dependency, you also get a special gift of 2829 files (198MB) in yourbower_components/
dir. Imagine the unnecessary file system reads and copies that are happening there.Here is a snippet of my cleaned dir structure:
Notice that only the
.js
files remain, I removed everything else. That's 2827 removed files. Highcharts is an extreme example, but most of your dependencies have 5 times as many files than you actually need.Positive future ahead
The
ember-cli
team are hard at work improving performance of the underlying broccoli ecosystem. Work has already begun and some real world apps (with large trees) are seeing performance improvements reducing rebuild time from 4 seconds to 600ms. Using symlinks instead of copying is showing drastic improvements.For those of us who have large scale apps, lots of bower deps and many crying team members, who need a solution now:
A temporary solution
One way of keeping your
bower_components/
clean, is to check the dependencies into version control. This allows you to usegit clean
to prune your directory with ease:Every time you do a
bower install
you will likely get all the extra cruft back in your dir.git clean
easily removes non version controlled files:After doing this, it took a single rebuild (time to build after changing a file) from 20 seconds down to 3.5 seconds (we have a pretty large app).
If you do go this path, dont forget the bower deps needed by Ember:
Here's the git command for you: