Using RAMDisk to Speed Build Times
Now that computers with 64-bit operating systems and 8 or 12 GB of RAM are pretty affordable, there are some fairly easy things you can do to speed up your build time for large project. Jeffrey Palermo wrote about six months ago about a few options for using RAM drives to speed up builds, and at the time my primary laptop only had 3GB of RAM so I wasn’t able to take advantage of his advice. However, recently I’ve gotten a new laptop and maxed it out with 8GB of RAM and Windows 7 64-bit.
Like Jeffrey, I have a ClickToBuild.bat file that will run my build as well as run all of the unit and integration tests for a given project. I set up a 1GB RAMDisk using Dataram RAMDisk (free version!).
Next, I ran my ClickToBuild.bat script from my laptop’s 7200 RPM hard drive. Note that most of the time spent is in the integration tests, which go against a local SQL Server database, which is running on the hard drive. At the moment I’m in the middle of fixing a problem in the build, but the Time Elapsed is the important aspect to show here:
So, not quite 3 minutes to run the solution with all of its unit and integration tests off of the C magnetic drive. Next, I copied the folder to my G drive, which is the 1GB RAMDisk, and ran the exact same script again.
Total time: 2 minutes 7 seconds – about 27% faster. Again, the database calls are all still going against my local SQL Server, which is still on the C (magnetic) drive, so these gains are primarily in the build and unit-test load/exec times. I haven’t yet tried putting the database into a RAMDisk. I’m guessing it would help, but probably not too dramatically since SQL Server will already aggressively use available memory to cache things. Perhaps for first-time loading it would make a difference, as that data would tend not to be in the cache and thus would need to come off of (slow) disk the first time.
27% may not sound like a lot to some people. Building and running tests is something that, if you’re head-down writing code, you are probably doing several times per hour. If you can shave a minute off of that time, you’re probably saving 3-5 minutes or more per hour, times 8 hours per day is 24-40 minutes per day. Now, sure, there are things you can do while your app is compiling:
…but you and your our customers would much rather you were able to get back to coding sooner rather than later. A few minutes per hour adds up to real productivity (and $ at any reasonable billing rate), and that’s before we even start talking about the value of having short feedback cycles to help detect and correct defects.
With the Dataram RAMDisk product, you can have it automatically serialize the disk to/from your persistent hard drive on startup/shutdown. Since it really is just RAM, a sudden power outage or BSOD will lose all of the data, but this is quite tolerable if all you’re using it for is source code that is already in your SCC repository (and of course you check in ALL THE TIME because small check-ins are amazingly better than huge ones). Thus, the amount of work you might ever lose as a result of the disk disappearing should be minimal.
Don’t put stuff you don’t have a backup of into a RAMDisk. That is all.

9 Comments
Binoj Antony said
Well, you really need 8-12 GB RAM to do this?
I run Virtual Server 2005 R2 on my system with 4 GB RAM, allocated 1GB to the VM, it works alright. I guess this should work the same for RAMDisk, unless some extra memory is being consumed by the RAM disk utility...
Twitter Trackbacks for Using RAMDisk to Speed Build Times : Steve Smith's Blog [stevesmithblog.com] on Topsy.com said
Pingback from Twitter Trackbacks for Using RAMDisk to Speed Build Times : Steve Smith's Blog [stevesmithblog.com] on Topsy.com
Interesting Finds: December 23, 2009 said
Interesting Finds: December 23, 2009
Using RAMDisk to Speed Build Times said
Steve Smith just wrote an interesting blog post about using RAMDisk to speed build time for code projects.
Paula Gerat said
I was always afraid of improving my machine's results. I'm not an computer expert and just thought that risking overheating central unit is not a good idea... This article could prove to be useful. Thanks.
Social comments and analytics for this post said
This post was mentioned on Twitter by ardalis: Blog: Using RAMDisk to Speed Build Times: Now that computers with 64-bit operating systems and 8 or 12 GB of RAM ar... <a target="_blank" href="http://bit.ly/5XcUu4">http://bit.ly/5XcUu4</a>
Peter Kellner said
My experiments have shown that the biggest impact is to put visual studio 2008 on an SSD. If I recall, I think I was going from 50 seconds to 20 seconds to rebuild all on one project. Moving the project itself to the SSD made almost no difference.
Morten Lyhr said
Remeber to measure before using a RAM disk.
I have found that for a particular solution a RAM drive is not the fastest builder.
<a target="_blank" href="http://morten.lyhr.dk/2010/01/optimizing-build-times.html">morten.lyhr.dk/.../optimizing-buil</a>
Tariq Salah said
This is a very good solution with many thanks. My editor also becomes faster when I set resharper and coderush to use the temp ramdisk.