I thought I’d take another shot at reducing our build times. When we test our full legacy code, there’s a lot of slow integration tests involving mysql. I looked at using an in-memory database like H2-with-mysql-syntax but some of our code (e.g. table creation) is too mysql-specific. Next step: use a ram disk for Mysql. This is all based on Ubuntu 12.04.
Here’s a script that starts MySQL with the parameters to use /dev/shm for all files, and bootstraps in the root user and system tables. I have verified using iotop and iostat that nothing is written to actual disk with these settings.
As for performance? a full test run of our main data access library has gone from 4:11 to 3:41, about 11% faster. Not much really!
2 replies on “Running MySQL/InnoDB in-memory for unit tests”
You know I had the same issue about a year ago, and I just noticed that recent versions of H2 (specifically .172 and .173) added support for MySQL-specific syntax. One specific thing that’s helpful is you can now specify “ENGINE=InnoDB” on when creating tables.
Very cool, thanks for the tip!