my.urgas.eu

RSS

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.