Where developers come to connect, share, build and be inspired.

7

Make bundler crazy fast

16594 views


Paralellize gem installs

You can paralellize the installation of gems with bundler's jobs feature.

To use, simply run:

bundle install --jobs 3

This only works for bundler 1.4 or above

Or to enable globally for all future bundling:

bundle config --global jobs 3

Obviously jobs is the number you want to parallelize. Pick the number one less than the number of cores you have. If you don't, you may get deadlock errors.

Credit to @xianpants for the tip!

Disable documentation

Create a file at ~/.gemrc with:

gem: --no-rdoc --no-ri

Unless, of course, you use local documentation.

Comments

  • User-avatar

    choose the number of cores that you have on your machine. That will (in most cases) be optimal.

  • 7297c7484eb236c1b961b788f7a37112

    This will only work in the current --pre versions (1.4)

    $ gem install bundler
    Fetching: bundler-1.3.5.gem (100%)
    Successfully installed bundler-1.3.5
    1 gem installed
    $ bundle install --jobs 4
    Unknown switches '--jobs'
    
  • 8e2b996de3842c6ef7e68a82fa5f01f5

    Great idea with the global ~/.gemrc. I sometimes remember to add that flag when installing but very rarely.

    However, the --no-doc and --no-ri flags are deprecated in Ruby 2.0. So, the ~/.gemrc might be slightly improved as:

    gem: --no-document
    

    I disabled Rubygem documentation in thoughtbot's dotfiles based on this tip, edited for Ruby 2.0.

  • User-avatar

    As of Nov/3/2013, update to 1.4 (to use the parallelize feature) using:

    gem install bundler --pre
    
  • 8e2b996de3842c6ef7e68a82fa5f01f5

    I'm not someone who knows how many cores my machine has without looking it up. So, I think a slight improvement to the first line might be:

    number_of_cores=`sysctl -n hw.ncpu`
    bundle config --global jobs `expr $number_of_cores - 1`
    

    That should automatically pick one number less than the number of cores on the machine.

    I configured Bundler for parallel gem installs in thoughtbot's laptop script based on this tip, edited to dynamically use one number less than the number of cores on the machine.

  • 2014-07-31_18.14.34_hdr

    Noted!

  • 56acf3dce9676364b491eae7ecd736e6

    Neat. Works pretty good.

  • 0e8a012c6542299bec2bc94922a3ed27

    i wonder why bundler doesn't do this by default

Add a comment