https://gist.github.com/4136373
我们的 test suite,前后对比。
之前——
正常运行:95.72s in-memory 运行:76.34s
patch 之后——
正常运行:78.62s in-memory 运行:57.27s
:-)
Cool! For rvm user:
rvm get head && rvm install 1.9.3 1.9.3-p327-falcon --patch falcon
rvm get head // open new shell rvm reinstall 1.9.3 -p falcon
and more: https://gist.github.com/4136373
效果:
$ rvm use ruby-1.9.3-p194
$ time rails runner "puts :OK"
OK
rails runner "puts :OK" 6.00s user 3.30s system 19% cpu 47.955 total
$ rvm use ruby-1.9.3-p327-falcon
$ time rails runner "puts :OK"
OK
rails runner "puts :OK" 3.49s user 1.83s system 50% cpu 10.559 total
装不上,大家没用 clang?
Building 'ruby-1.9.3-p327-falcon' using clang - but it's not (fully) supported, expect errors.
Installing Ruby from source to: /Users/roymax/.rvm/rubies/ruby-1.9.3-p327-falcon, this may take a while depending on your cpu(s)...
ruby-1.9.3-p327-falcon - #downloading ruby-1.9.3-p327, this may take a while depending on your connection...
ruby-1.9.3-p327-falcon - #extracting ruby-1.9.3-p327 to /Users/roymax/.rvm/src/ruby-1.9.3-p327-falcon
ruby-1.9.3-p327-falcon - #extracted to /Users/roymax/.rvm/src/ruby-1.9.3-p327-falcon
Applying patch /Users/roymax/.rvm/patches/ruby/1.9.3/p327/falcon.diff
ruby-1.9.3-p327-falcon - #autoreconf
Error running 'autoreconf', please read /Users/roymax/.rvm/log/ruby-1.9.3-p327-falcon/autoreconf.log
ruby-1.9.3-p327-falcon - #configuring
Error running './configure --enable-shared --disable-install-doc --prefix=/Users/roymax/.rvm/rubies/ruby-1.9.3-p327-falcon --with-opt-dir=/Users/roymax/.rvm/usr', please read /Users/roymax/.rvm/log/ruby-1.9.3-p327-falcon/configure.log
There has been an error while running configure. Halting the installation.
Ruby 'ruby-1.9.3-p327-falcon' was built using clang - but it's not (fully) supported, expect errors.
参考http://astrails.com/blog/2012/11/13/rvm-install-patched-ruby-for-faster-rails-startup 加个参数竟然过了,-n falcon
参数是什么意思?
rvm get head && rvm install 1.9.3 1.9.3-p327-falcon --patch falcon -n falcon
$ time rails runner "puts :OK"
OK
rails runner "puts :OK" 6.32s user 1.37s system 92% cpu 8.292 total
$ rvm use ruby-1.9.3-p327-falcon
$ time rails runner "puts :OK"
OK
rails runner "puts :OK" 3.75s user 0.96s system 99% cpu 4.752 total
$ export RUBY_HEAP_MIN_SLOTS=1000000
$ export RUBY_HEAP_FREE_MIN=500000
$ export RUBY_HEAP_SLOTS_INCREMENT=1000000
$ export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1
$ export RUBY_GC_MALLOC_LIMIT=100000000
$ time rails runner "puts :OK"
OK
rails runner "puts :OK" 3.18s user 1.02s system 99% cpu 4.234 total
找个项目简单对比了下:
rvm-use-ruby-1.9.3-p194
rspec spec/models/
Finished in 45.81 seconds
70 examples, 0 failures, 2 pending
rvm-use-ruby-1.9.3-p327-falcon
rspec spec/models/
Finished in 32.36 seconds
70 examples, 0 failures, 2 pending
效果杠杠的!