Thursday, December 15, 2011

Ubuntu, MySQL, Slow Rspec tests

I couldn't for the life of me figure out why my 200 simple rspec tests were running so painfully slow on my Ubuntu partition and so quickly in Debian on VirtualBox running in a Windows 7 Host. Apparently, Ubuntu allows the use of barriers on ext4 partitions by default.

You can learn more about the purpose of barriers here: Deciding when to use Linux file system barriers

To disable barriers, open up your /etc/fstab file in an editor of your liking (as sudo).

Look for the line that describes the partition you are running Ubuntu on. For example:

UUID=f54ae48f-7525-4b18-92bf-dbe5b1fb9be6 / ext4 errors=remount-ro 0 1

Add a barrier=0 option so it now looks like this:

UUID=f54ae48f-7525-4b18-92bf-dbe5b1fb9be6 / ext4 barrier=0,errors=remount-ro 0 1

Restart and run rspec. You should see a noticeable difference.

3 comments:

  1. Thank you so much for this post! My specs were taking over an hour to run. This solution reduced run time by a factor of 4!

    ReplyDelete