02 October 2014
I started playing with Ember recently, and I decided to develop using Ember CLI. This live compiles your JavaScript as each file changes and adds some hooks so the webpage refreshes when the code changes.
One thing that nearly made me give up on Ember CLI is that it just seemed too slow. I am developing on a 3ish year old Macbook Pro with an old fashioned spinning disk, so its not exactly state of the art hardware. Each time I changed a file it took 3 to 4 seconds to compile, and that was on a very small app.
I came across this page that suggested slowness is often caused by lots of files that need to be read and written in the project tmp directory, so that got me thinking - what if the tmp folder wasn't on disk, and just lived in memory?
On OS X creating a RAM disk is easy, I created one using the following script:
# The number at the end is 512 MB, set by 2028*512 = 1048576
diskutil erasevolume HFS+ 'RAM Disk' `hdiutil attach -nomount ram://1048576`
mkdir /Volumes/RAM\ Disk/ember
Then I deleted my Ember projects tmp directory and created a sym link to /Volumes/RAM Disk/ember - my compile times instantly dropped to about 1 second, which I think is tolerable.
I'm hoping to get an SSD in this old machine soon, but until then this hack keeps my build times tolerable.