Skip to content

Instantly share code, notes, and snippets.

@Capncavedan
Last active August 29, 2015 13:56
Show Gist options
  • Save Capncavedan/8810555 to your computer and use it in GitHub Desktop.
Save Capncavedan/8810555 to your computer and use it in GitHub Desktop.
Speed up your Ruby Travis CI build with this one weird old trick ...

OK, it's two weird old tricks.

First, use their bundle caching feature. It's one line added to your .travis.yml file, and significantly speeds up test runs where you haven't changed your gem bundle - which is most of the time for most people.

See more here: http://blog.travis-ci.com/2013-12-05-speed-up-your-builds-cache-your-dependencies/

Second, do some experimentation with your Ruby garbage collection settings to speed up your local test suite runs. Examples from our development environment:

# Ruby 1.9 and 2.0 performance optimization
export RUBY_HEAP_MIN_SLOTS=5000000
export RUBY_HEAP_FREE_MIN=50000
export RUBY_HEAP_SLOTS_INCREMENT=100000
export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1
export RUBY_GC_MALLOC_LIMIT=1000000000

Add these to a .travis.yml file like so:

env:
  - RUBY_HEAP_MIN_SLOTS=5000000 RUBY_HEAP_FREE_MIN=50000 RUBY_HEAP_SLOTS_INCREMENT=100000 RUBY_HEAP_SLOTS_GROWTH_FACTOR=1 RUBY_GC_MALLOC_LIMIT=1000000000

These two tricks enabled me to get a CI run on one of our projects down from 16m 22s total to 4m 37s total. Big win.

@sarahhodne
Copy link

Suggestion for adding them to the .travis.yml: You can also add them to env.global, which doesn't make new matrix jobs if you are using environment variables for sometihng else:

env:
  global:
    - RUBY_HEAP_MIN_SLOTS=5000000
    - RUBY_HEAP_FREE_MIN=50000
    - RUBY_HEAP_SLOTS_INCREMENT=100000
    - RUBY_HEAP_SLOTS_GROWTH_FACTOR=1
    - RUBY_GC_MALLOC_LIMIT=1000000000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment