my.urgas.eu

RSS

Posts tagged with "performance"

Speeding up RSpec test suite: Tip #3

Assuming you are using ruby 1.9.3-p0 at the moment, then I suggest applying funny-falcon patch (https://gist.github.com/1688857). This made my rails start up faster and also the overall runtime.

This is also included in the RVM. To install it, just run:

rvm get head
rvm install 1.9.3-falcon
rvm use 1.9.3-falcon

I also suggest adding following to your shell rc file (bonus section from the gist). This basically calms down the garbage collector. It has almost same effect as disabling GC completely in the specs (tip #2).

export RUBY_HEAP_MIN_SLOTS=1000000
export RUBY_HEAP_SLOTS_INCREMENT=1000000
export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1
export RUBY_GC_MALLOC_LIMIT=1000000000
export RUBY_HEAP_FREE_MIN=500000

Speeding up RSpec test suite: Tip #2

Got lots of RAM? Disable GC.

I have this snippet in my spec_helper.rb

  if ENV["RUBY_DISABLE_GC_FOR_SPECS"]
    config.before(:suite) do
      puts "GC disabled"
      GC.disable
    end
  end

And in my shell rc file I have:

export RUBY_DISABLE_GC_FOR_SPECS="true"

Warning: If you have many selenium tests, then do not disable it completely. You’ll just run out of RAM.

Speeding up RSpec test suite: Tip #1

If your test suite is database heavy and you are using postgresql, then turn off fsync and synchronous_commit.

fsync - PostgreSQL server will try to make sure that updates are physically written to disk (link). In the development machine we usually don’t care about power failures and data loss, especially with the test data.

synchronous_commit - Specifies whether transaction commit will wait for WAL records to be written to disk before the command returns a “success” indication to the client (link).

You can change these settings in the postgresql.conf. Just set:

fsync = off
synchronous_commit = off

My test suite time with default options (using ssd): 105 seconds.

My test suite time with fsync and synchronous_commit turned off: 30 seconds.