2011-01-27 53 views
2

編輯:有點不同(和更少)的瓶頸用捆紮機1.0.9代替1.0.3。RubyGems的和捆紮機:慢速啓動

我對Rails的的慢啓動時間非常惱火(因爲我反覆運行測試),所以我試圖找出使用poor-man's profiling的罪魁禍首,通過運行rails console --help(它加載我所有的寶石)反覆,擊中Ctrl + C,然後查看堆棧跟蹤。

從像 active_support和朋友明顯的罪魁禍首

除了被加載,在某些時候(可能是10%左右),輸出類似於此:

$ 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 `<top (required)>' 
    from <internal:lib/rubygems/custom_require>:29:in `require' 
    from <internal:lib/rubygems/custom_require>:29:in `require' 
    from script/rails:5:in `<main>' 

如此看來,相當長的一段時間花費加載gemspecs。

是否有某種方式來加速這個嗎?骯髒的黑客也是讚賞 - 我只想運行我的測試套件沒有(很多)延遲。

+1

捆綁1.0.3真的在我看來馬車。安裝最新的,我認爲它的1.0.9。 – 2011-01-27 21:37:15

+0

啊,運行`bundle update`時它不會被更新。當然,我猜。所以我跑了`sudo gem update bundler`,現在我的版本是1.0.9。再試一次,它看起來可能稍微快一些,瓶頸現在在`rubygems`包中。我會在一秒內更新這個問題。 – 2011-01-27 21:51:38

回答

1

更新到這一點:tconsole實在是太酷,如果你正在使用MINITEST。