title: Rubygems and Bundler: Slow startup
body: <p><em>Edit: Somewhat different (and fewer) bottlenecks with Bundler 1.0.9 instead of 1.0.3.</em></p>
  
  <p>I'm terribly annoyed by Rails's slow startup time (since I run tests repeatedly), so I'm trying to find out the culprit is using <a href="https://stackoverflow.com/questions/375913/what-can-i-use-to-profile-c-code-in-linux/378024#378024">poor-man's profiling</a>, by running <code>rails console --help</code> (which loads all my gems) repeatedly, hitting Ctrl+C, and looking at the stack trace.</p>
  
  <p>Apart from the obvious culprits like <code>active_support</code> and friends being loaded, some of the time (perhaps 10% or so), the output looks similar to this:</p>
  
  <pre><code>$ rails console --help
  ^C/var/lib/gems/1.9.1/specifications/i18n-0.5.0.gemspec:3:in `new': Interrupt
      from /var/lib/gems/1.9.1/specifications/i18n-0.5.0.gemspec:3:in `load_specification'
      from /usr/lib/ruby/1.9.1/rubygems/source_index.rb:95:in `eval'
      from /usr/lib/ruby/1.9.1/rubygems/source_index.rb:95:in `load_specification'
      from /usr/lib/ruby/1.9.1/rubygems/source_index.rb:153:in `block (2 levels) in load_gems_in'
      from /usr/lib/ruby/1.9.1/rubygems/source_index.rb:152:in `each'
      from /usr/lib/ruby/1.9.1/rubygems/source_index.rb:152:in `block in load_gems_in'
      from /usr/lib/ruby/1.9.1/rubygems/source_index.rb:149:in `reverse_each'
      from /usr/lib/ruby/1.9.1/rubygems/source_index.rb:149:in `load_gems_in'
      from /usr/lib/ruby/1.9.1/rubygems/source_index.rb:345:in `refresh!'
      from /usr/lib/ruby/1.9.1/rubygems/source_index.rb:78:in `from_gems_in'
      from /usr/lib/ruby/1.9.1/rubygems/source_index.rb:58:in `from_installed_gems'
      from /usr/lib/ruby/1.9.1/rubygems.rb:866:in `source_index'
      from /var/lib/gems/1.9.1/gems/bundler-1.0.9/lib/bundler/source.rb:161:in `installed_specs'
      from /var/lib/gems/1.9.1/gems/bundler-1.0.9/lib/bundler/source.rb:151:in `block in fetch_specs'
      from /var/lib/gems/1.9.1/gems/bundler-1.0.9/lib/bundler/index.rb:7:in `build'
      from /var/lib/gems/1.9.1/gems/bundler-1.0.9/lib/bundler/source.rb:150:in `fetch_specs'
      from /var/lib/gems/1.9.1/gems/bundler-1.0.9/lib/bundler/source.rb:65:in `specs'
      from /var/lib/gems/1.9.1/gems/bundler-1.0.9/lib/bundler/definition.rb:159:in `block (2 levels) in index'
      from /var/lib/gems/1.9.1/gems/bundler-1.0.9/lib/bundler/definition.rb:158:in `each'
      from /var/lib/gems/1.9.1/gems/bundler-1.0.9/lib/bundler/definition.rb:158:in `block in index'
      from /var/lib/gems/1.9.1/gems/bundler-1.0.9/lib/bundler/index.rb:7:in `build'
      from /var/lib/gems/1.9.1/gems/bundler-1.0.9/lib/bundler/definition.rb:157:in `index'
      from /var/lib/gems/1.9.1/gems/bundler-1.0.9/lib/bundler/definition.rb:151:in `resolve'
      from /var/lib/gems/1.9.1/gems/bundler-1.0.9/lib/bundler/definition.rb:90:in `specs'
      from /var/lib/gems/1.9.1/gems/bundler-1.0.9/lib/bundler/definition.rb:135:in `specs_for'
      from /var/lib/gems/1.9.1/gems/bundler-1.0.9/lib/bundler/definition.rb:124:in `requested_specs'
      from /var/lib/gems/1.9.1/gems/bundler-1.0.9/lib/bundler/environment.rb:23:in `requested_specs'
      from /var/lib/gems/1.9.1/gems/bundler-1.0.9/lib/bundler/runtime.rb:11:in `setup'
      from /var/lib/gems/1.9.1/gems/bundler-1.0.9/lib/bundler.rb:101:in `setup'
      from /home/jo/src/mercury/config/boot.rb:8:in `&lt;top (required)&gt;'
      from &lt;internal:lib/rubygems/custom_require&gt;:29:in `require'
      from &lt;internal:lib/rubygems/custom_require&gt;:29:in `require'
      from script/rails:5:in `&lt;main&gt;'
  </code></pre>
  
  <p>So it seems that quite some time is spent loading gemspecs.</p>
  
  <p>Is there some way to speed this up?  Dirty hacks are appreciated too -- I just want to run my test suite without (so much) delay.</p>