public
Last active — forked from funny-falcon/cumulative_performance.patch

ruby-1.9.3-p327 cumulative performance patch for rbenv

  • Download Gist
0-readme.md
Markdown

ruby-1.9.3-p327 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

Ok, let's do this!

curl https://raw.github.com/gist/1688857/rbenv.sh | sh ; rbenv global 1.9.3-p327-perf

BONUS!

Putting the following in your shell config (eg. ~/.bash_profile) will make Rails even faster, but will increase its memory footprint. For most applications, this will probably work well for you:

export RUBY_GC_MALLOC_LIMIT=60000000
export RUBY_FREE_MIN=200000

If you have a particularly large rails app (say, >100k lines), this seems to improve it even more:

export RUBY_GC_MALLOC_LIMIT=1000000000
export RUBY_FREE_MIN=500000
export RUBY_HEAP_MIN_SLOTS=40000

More BONUS!

If you're feeling adventurous, you can set some additional compile flags before you run the command above. These may cause the build to fail. If so, you can try again without the march flag, and it'll probably work. This generally makes my ruby ~1.5% faster. See http://en.gentoo-wiki.com/wiki/Safe_Cflags/Intel for more guidance. I had to change it to -march=core2 on my Macbook Air 2011/11".

export CFLAGS="-march=native -O3 -pipe -fomit-frame-pointer"

This has to be run BEFORE you compile ruby.

2-1.9.3-p327-patched.sh
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
build_package_combined_patch() {
local package_name="$1"
 
{
curl https://raw.github.com/gist/4136373/falcon-gc.diff | patch -p1
autoconf
./configure --prefix="$PREFIX_PATH" $CONFIGURE_OPTS
make -j 8
make install
} >&4 2>&1
 
}
 
install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz"
install_package "ruby-1.9.3-p327" "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p327.tar.gz" combined_patch
rbenv.sh
Shell
1 2 3
VERSION="1.9.3-p327"
curl https://raw.github.com/gist/1688857/2-$VERSION-patched.sh > /tmp/$VERSION-perf
rbenv install /tmp/$VERSION-perf

Wow :) it is great :) thank you

Very nice! The difference in rails boot time is significant. Waiting for these patches to land in the next ruby release :)

Thanks for sharing that. Indeed the speed increase is quite impressive! I've tested the time it take to run some rspec test before and after. Here are the results:

Before: Finished in 402.79 seconds (3521 examples, 3 failures, 39 pending)
After: Finished in 222,82 seconds (3521 examples, 3 failures, 39 pending). WOOW!

However installation of the patch was not as straightforward as you suggested (I'm using rvm). The first error I got:

 sh: cannot create /home/dorian/.rvm/patches/ruby/1.9.3/p0/falcon.patch: Directory nonexistent

The solution was to manually create the folder /home/dorian/.rvm/patches/ruby/1.9.3/p0. The second error I got:

ERROR: Unrecognized command line argument: 'falcon.patch' ( see: 'rvm usage' )

I've fixed that by manualy running the following command:

rvm install 1.9.3-perf --patch $rvm_path/patches/ruby/1.9.3/p0/falcon.patch

Thanks again for your this patch!

Dorian

P.S. I've put the bonus tweaks in /etc/profile (Ubuntu)

Thanks @dlupu! I added your changes, so hopefully it'll work right away for the next rvm user to try it.

I ran into the following

RVM is not a function, selecting rubies with 'rvm use ...' will not work.

at the end of the installation, but otherwise it seemed to go well.

Obligatory benchmarks:

Test Suite on 1.9.3-p0 proper : 2m06s
Rails boot time : 9.1s

Suite on 1.9.3-p0-perf : 1m32s
Rails boot time : 6.5s

Not bad.

Nice:

$ time rake

before:
real 0m37.919s
user 0m6.474s
sys 0m0.919s

after:
real 0m34.236s
user 0m3.367s
sys 0m0.848s

$ time rails runner "Time.now"

before:
real 0m4.589s
user 0m3.871s
sys 0m0.629s

after:
real 0m2.437s
user 0m1.889s
sys 0m0.534s

included in rvm:

rvm get head
rvm reinstall 1.9.3-p0-falcon --patch falcon -j 3

@mpapis

noice-macbook:~% rvm get head
...
ruby-1.9.3-p0-falcon - #fetching 
ruby-1.9.3-p0-falcon - #extracting ruby-1.9.3-p0 to /Users/daliborfilus/.rvm/src/ruby-1.9.3-p0-falcon
ruby-1.9.3-p0-falcon - #extracted to /Users/daliborfilus/.rvm/src/ruby-1.9.3-p0-falcon
Patch 'falcon' not found.
ruby-1.9.3-p0-falcon - #configuring 
...

It completed, but notice that message "Patch 'falcon' not found.".

But it is there...

noice-macbook:~% ls ~/.rvm/patches/ruby/1.9.3/p0/falcon.patch 
/Users/daliborfilus/.rvm/patches/ruby/1.9.3/p0/falcon.patch

running rails runner "puts \"yeah\"" yields the same speed as the base 1.9.3-p0 version...

EDIT:

I did it this way now:


noice-macbook:~/ % export patchdir=$rvm_path/patches/ruby/1.9.3/p0
noice-macbook:~/ % rvm install 1.9.3 -n falcon --patch $patchdir/falcon.patch
...
ruby-1.9.3-p0-falcon - #fetching 
ruby-1.9.3-p0-falcon - #extracting ruby-1.9.3-p0 to /Users/daliborfilus/.rvm/src/ruby-1.9.3-p0-falcon
ruby-1.9.3-p0-falcon - #extracted to /Users/daliborfilus/.rvm/src/ruby-1.9.3-p0-falcon
Applying patch '/Users/daliborfilus/.rvm/patches/ruby/1.9.3/p0/falcon.patch' (located at //Users/daliborfilus/.rvm/patches/ruby/1.9.3/p0/falcon.patch)
ruby-1.9.3-p0-falcon - #autoreconf

So far so good.
The difference: rvm install 1.9.3-p0-falcon --patch falcon -j 3
vs. rvm install 1.9.3 -n falcon --patch $patchdir/falcon.patch

P.S. the second variant preserves your 1.9.3 gems...

5.5 secs instead of 8.8 secs for rails runner "puts \"omfg\""
rspec . 15.1 seconds instead of 18.2 seconds
(of course I ran those at least 3 times each, to warm file system caches)

Thanks all involved, it's nice to see ruby faster and faster :)

Not working with Xcode 4.2 on Lion, any tricks to make ir work or should I just install GCC?

in rvm you can read rvm requirements it should show you what to do

Yeah I know about --with-gcc=clang but it fails

Error running 'patch -F 25 -p1 -N -f
<"//Users/aftakitani/.rvm/patches/ruby/1.9.3/p0/falcon.patch"', please read
/Users/aftakitani/.rvm/log/ruby-1.9.3-p0-perf/patch.apply.falcon.patch.log

And the log is empty

On Sun, Jan 29, 2012 at 4:14 PM, Michal Papis <
reply@reply.github.com

wrote:

in rvm you can read rvm requirements it should show you what to do


Reply to this email directly or view it on GitHub:
https://gist.github.com/1688857

are you sure you run rvm reinstall ? using --force is applying patch again, which will fail (can not apply the same patch two times)

Well I'll try later with clang but worked with osx-gcc. Thanks!

BTW, it breaks the ruby-debug gem:

/Users/roman/.rvm/gems/ruby-1.9.3-p0-falcon@musdom/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:251:in `require': dlopen(/Users/roman/.rvm/gems/ruby-1.9.3-p0-falcon@musdom/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.bundle, 9): Symbol not found: _ruby_current_thread (LoadError)
Referenced from: /Users/roman/.rvm/gems/ruby-1.9.3-p0-falcon@musdom/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.bundle
Expected in: flat namespace
in /Users/roman/.rvm/gems/ruby-1.9.3-p0-falcon@musdom/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.bundle - /Users/roman/.rvm/gems/ruby-1.9.3-p0-falcon@musdom/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.bundle
.... such a shame....

@mindreframer My patch didn't touch _ruby_current_thread . Could you check, if https://github.com/wayneeseguin/rvm/blob/master/patches/ruby/1.9.3/p0/debug.diff is applied?

there is another patch for ruby-debug:

rvm reinstall 1.9.3-falcon --patch falcon,debug --force-autoconf -j 3

do not forget to reinstall the gem after reisntalling ruby

@mpapis:
Well, reinstalled with debug patch and then installed ruby-debug19 (after removing it, just installing over current didn't work).... still an error:

/Users/roman/.rvm/gems/ruby-1.9.3-p0-falcon@musdom/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:251:in `require': dlopen(/Users/roman/.rvm/gems/ruby-1.9.3-p0-falcon@musdom/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.bundle, 9): Symbol not found: _ruby_threadptr_data_type (LoadError)
Referenced from: /Users/roman/.rvm/gems/ruby-1.9.3-p0-falcon@musdom/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.bundle
Expected in: flat namespace
in /Users/roman/.rvm/gems/ruby-1.9.3-p0-falcon@musdom/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.bundle - /Users/roman/.rvm/gems/ruby-1.9.3-p0-falcon@musdom/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.bundle
...

Some other suggestions?

specs:
osx 10.6.6
macbook pro 2.7 GHz i7
latest rvm...

just tried it with a clean gemset...
irb:

require 'ruby-debug'
LoadError: dlopen(/Users/roman/.rvm/gems/ruby-1.9.3-p0-falcon@global/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.bundle, 9): Symbol not found: _ruby_threadptr_data_type
Referenced from: /Users/roman/.rvm/gems/ruby-1.9.3-p0-falcon@global/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.bundle
Expected in: flat namespace
in /Users/roman/.rvm/gems/ruby-1.9.3-p0-falcon@global/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.bundle - /Users/roman/.rvm/gems/ruby-1.9.3-p0-falcon@global/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.bundle

there is a thread related to the debug problem: https://gist.github.com/1329273

@mpapis:
Thx a lot!

this solved it for now:

wget http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem
wget http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem

gem install linecache19-0.5.13.gem
## with rvm: 
gem install ruby-debug-base19-0.11.26.gem -- --with-ruby-include=$HOME/.rvm/src/ruby-1.9.3-p0-falcon
## with rbenv (this is a guess): 
gem install ruby-debug-base19-0.11.26.gem -- --with-ruby-include=$HOME/.rbenv/source/ruby-1.9.3-p0-falcon

For the RVM script, line 5 (rvm use 1.9.3-perf) wont work on the stable branch.
It should be changed to:
rvm 1.9.3-perf
which will work in stable and, at least, a few older versions.
The rest works great.

Thanks!

When running against rvm, I got an error that "RVM is not a function, selecting rubies with 'rvm use ...' will not work." My guess is that piping the script to run in bash instead of sh would fix that, since rvm is loaded in my .bash_profile.

I'm getting -
pool_alloc.inc.h:55:2: error: #error no memalign function

On OS X 10.5.8

One of my Rails apps, boot time (measured with ./bin/rails runner 'puts 3'

1.9.3-perf:  5.1 seconds
1.9.3-p0:    8.1 seconds
1.9.2-p290: 18.2 seconds

@shanlalit It seems that there is no memalign-like function in OS X before 10.6 :(

Could you check, if ruby-trunk builds on your platform? If not, than that is a reason to make a bug report at https://bugs.ruby-lang.org/projects/ruby-trunk/issues .

Additional request: could you change DEFAULT_POOL_SIZE to 4096 in pool_alloc.inc.h and then change line 55 from #error no memalign function to res = valloc(size); ?

should autoconf be autoreconf?

I use it in Arch Linux and some stdlib are missed, including socket.rb . It is fixed after reinstalling by changing autoconf to autoreconf

UPDATED: install though rbenv

I use it on Arch Linux too and, with RVM, was straightforward. Except for the 'rvm use' issue I described above.

Will this be included upstream/ in the next official ruby release?

@funny-falcon I didn't tried ruby-trunk.

I am still getting error as below, after following your suggestions.
32 pool_alloc.inc.h:55:2: error: #error no memalign function

Then I tried to re-install with the patch -
curl https://raw.github.com/gist/1688857/rvm.sh | sh
this results in two errors
1. In .rvm/log/ruby-1.9.3-p0-perf/patch.apply.falcon.patch.log

[2012-02-01 00:27:42] patch -F 25 -p1 -N -f <"//Users/lalitshandilya/.rvm/patches/ruby/1.9.3/p0/falcon.patch"
patching file common.mk
Hunk #1 FAILED at 629.
Hunk #2 FAILED at 693.
2 out of 2 hunks FAILED -- saving rejects to file common.mk.rej
patching file configure.in
Hunk #1 FAILED at 1406.
1 out of 1 hunk FAILED -- saving rejects to file configure.in.rej
patching file gc.c
Hunk #1 succeeded at 20 with fuzz 3.
Hunk #2 succeeded at 36 with fuzz 3.
Hunk #3 succeeded at 365 with fuzz 2 (offset 48 lines).
Hunk #4 succeeded at 392 with fuzz 3 (offset 48 lines).
Hunk #5 succeeded at 454 with fuzz 3 (offset 60 lines).
Hunk #6 succeeded at 491 with fuzz 3 (offset 60 lines).
Hunk #7 succeeded at 572 with fuzz 3 (offset 60 lines).
Hunk #8 succeeded at 3687 with fuzz 1 (offset 2760 lines).
patching file internal.h
Hunk #1 succeeded at 108 with fuzz 3.
patching file load.c
Hunk #1 succeeded at 4 with fuzz 3.
Hunk #2 succeeded at 620 with fuzz 2 (offset 601 lines).
Hunk #3 FAILED at 630.
Hunk #4 succeeded at 795 with fuzz 2 (offset 648 lines).
Hunk #5 FAILED at 820.
Hunk #6 FAILED at 847.
Hunk #7 succeeded at 953 with fuzz 2 (offset 679 lines).
Hunk #8 FAILED at 1124.
Hunk #9 succeeded at 1749 with fuzz 1 (offset 799 lines).
Hunk #10 FAILED at 1981.
5 out of 10 hunks FAILED -- saving rejects to file load.c.rej
The next patch would create the file pool_alloc.h,
which already exists! Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file pool_alloc.h.rej
The next patch would create the file pool_alloc.inc.h,
which already exists! Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file pool_alloc.inc.h.rej
patching file ruby.c
Hunk #1 FAILED at 209.
Hunk #2 FAILED at 216.
Hunk #3 FAILED at 337.
Hunk #4 FAILED at 436.
Hunk #5 FAILED at 449.
Hunk #6 succeeded at 1079 with fuzz 2 (offset -267 lines).
5 out of 6 hunks FAILED -- saving rejects to file ruby.c.rej
patching file st.c
Hunk #1 succeeded at 7 with fuzz 3.
Hunk #2 succeeded at 28 with fuzz 3.
Hunk #3 FAILED at 65.
Hunk #4 FAILED at 167.
Hunk #5 FAILED at 243.
Hunk #6 FAILED at 261.
Hunk #7 FAILED at 338.
Hunk #8 FAILED at 351.
Hunk #9 FAILED at 392.
Hunk #10 FAILED at 468.
Hunk #11 FAILED at 504.
Hunk #12 FAILED at 670.
Hunk #13 FAILED at 714.
Hunk #14 FAILED at 758.
Hunk #15 FAILED at 784.
Hunk #16 FAILED at 803.
Hunk #17 FAILED at 827.
Hunk #18 FAILED at 872.
Hunk #19 FAILED at 898.
Hunk #20 FAILED at 921.
Hunk #21 FAILED at 949.
Hunk #22 FAILED at 963.
Hunk #23 FAILED at 1018.
Hunk #24 FAILED at 1026.
Hunk #25 succeeded at 1039 with fuzz 3.
Hunk #26 FAILED at 1061.
Hunk #27 FAILED at 1084.
Hunk #28 FAILED at 1109.
Hunk #29 FAILED at 1142.
26 out of 29 hunks FAILED -- saving rejects to file st.c.rej
patching file vm.c
Hunk #1 succeeded at 1575 with fuzz 3.
patching file vm_core.h
Hunk #1 succeeded at 298 with fuzz 3.

and 2. In .rvm/log/ruby-1.9.3-p0-perf/make.log

[2012-02-01 00:28:24] make
CC = /usr/bin/gcc-4.2
LD = ld
LDSHARED = /usr/bin/gcc-4.2 -dynamiclib
CFLAGS = -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Werror=pointer-arith -Werror=write-strings -Werror=declaration-after-statement -Werror=shorten-64-to-32 -Werror=implicit-function-declaration -fno-common -pipe
XCFLAGS = -include ruby/config.h -include ruby/missing.h -fvisibility=hidden -DRUBY_EXPORT
CPPFLAGS = -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I. -I.ext/include/i386-darwin9.8.0 -I./include -I.
DLDFLAGS = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -Wl,-flat_namespace -install_name /Users/lalitshandilya/.rvm/rubies/ruby-1.9.3-p0-perf/lib/libruby.1.9.1.dylib -current_version 1.9.1 -compatibility_version 1.9.1 -Wl,-unexported_symbol,Init* -Wl,-unexported_symbol,threadptr -Wl,-u,_objc_msgSend

SOLIBS =
compiling dmyencoding.c
compiling miniprelude.c
In file included from miniprelude.c:8:
vm_core.h:302: error: duplicate member 'load_path_expanded_cache'
vm_core.h:303: error: duplicate member 'load_path_expanded_cache'
make: *** [miniprelude.o] Error 1

Does it gives you any other clues on what's going on?

@shanlalit : you should remove ~/.rvm/src/ruby-1.9.3-p0-perf before trying to reinstall it.

I recommend you install https://gist.github.com/1484985 untill I fix issue with missed memalign - the main startup improvement is gained from this patch.

patchdir=$rvm_path/patches/ruby/1.9.3/p0
mkdir -p $patchdir
curl https://raw.github.com/gist/1484985/cached_lp_sorted_lf.patch > $patchdir/falcon.patch
rvm install 1.9.3 -n perf --patch $patchdir/falcon.patch
rvm use 1.9.3-perf

All good, but tests not runing:

$ rake --trace
** Invoke default (first_time)
** Invoke spec (first_time)
** Invoke db:test:prepare (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
stack level too deep
/Users/leo/.rvm/gems/ruby-1.9.3-p0-perf@global/gems/rake-0.9.2.2/lib/rake/task.rb:162
Tasks: TOP => default => spec => db:test:prepare => db:abort_if_pending_migrations => environment

How to fix this?

ok, all right, if I run all rake tasks with 'bundle exec'. Infinite loop only without bundler :)

@le0pard , so tell me: is it bug of patch, or you have same error without patch?

@funny-falcon

$ rvm use ruby-1.9.3-p0-perf
Using /Users/leo/.rvm/gems/ruby-1.9.3-p0-perf
$ rake db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
stack level too deep
/Users/leo/.rvm/gems/ruby-1.9.3-p0-perf@global/gems/rake-0.9.2.2/lib/rake/task.rb:162
Tasks: TOP => db:migrate => environment
$ bundle exec rake db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
** Execute db:migrate
** Invoke db:_dump (first_time)
** Execute db:_dump
** Invoke db:schema:dump (first_time)
** Invoke environment
** Invoke db:load_config
** Execute db:schema:dump

@le0pard I emailed to you. Lets work on this error.

It seems to be not error of patch. Following reproduce error:

rvm install 1.9.3 -n test -j 2
rvm 1.9.3-test
gem install sqlite3 rails
rails new myapp
cd myapp
rake --trace

And get following error: https://gist.github.com/1725184
As you can see there, error is reproduced even with default 1.9.3-p0 installation by rvm.
Error is not exposed when nondefault gemset is used.

As I don't know which bug is it, I created reports both in rvm and ruby:
https://github.com/wayneeseguin/rvm/issues/741
http://bugs.ruby-lang.org/issues/5960

My rake parallel:spec went down from 68 to 38sec!!!!!!!!!! That's 44% cut off! Fantastic! THANK YOU!

I had the same problem when installing with RVM v1.9.2

Error running 'patch -F 25 -p1 -N -f

Upgraded RVM to the latest (v1.10.2):

rvm get latest

Then did:

rvm reinstall 1.9.3-falcon --patch falcon,debug --force-autoconf -j 3

Compiled and works great!!

API spec tests ~30% faster!

This is really cool. Would love to see this as a default in the Ruby by default.
Is this patch gonna be part of the Ruby next minor version?

time bundle exec rake environment

Before:
14.60s user 1.26s system 100% cpu 15.861 total

After:
5.11s user 1.10s system 99% cpu 6.212 total

60.8% speedup!!!!!!

After adding the additional memory tweaks:
4.02s user 1.18s system 99% cpu 5.205 total

67.1% speedup!!!!!!!!!!!!!!!

Average result of time bundle exec rake on current Rails project over 3 runs

OS X Lion on SSD

real 21.459 # before
real 17.303 # after

Ubuntu 11.04 on EC2

real 36.302 # before
real 21.961 # after

Weird. On one project, 2404 examples with patched Ruby: 13m2.045s. Unpatched: 13m2.262s :(

On another project with 1000 examples, I got a 9% better performance, though.

@kurko , I suppose, those tests produce heavy DB load, don't they?

Wow, incredible increase in start-up speed: saved me up to 40%! Thanks for sharing!

Before:

~/testproject (develop ✗) > rbfu @1.9.3-p0 time rake
Activated Ruby 1.9.3-p0 (from command line)
real 0m16.005s
user 0m11.464s
sys 0m2.446s

After:

~/testproject (develop ✗) > rbfu @1.9-patch time rake
Activated Ruby 1.9-patch. (from command line)
real 0m10.887s
user 0m8.033s
sys 0m1.702s


Btw. I am using rbfu https://github.com/hmans/rbfu (a simpler alternative to rbenv / rvm) to manage my Ruby versions. As an rbfu user you simply install your Rubies via the ruby-build script. To spare others the hassle, I added a script for that:

https://gist.github.com/1830994

patch 125 is out. Does it include these performance improvements?
http://www.ruby-lang.org/en/news/2012/02/16/ruby-1-9-3-p125-is-released/

No. Official ruby-1.9.3 will not add any "new features", only bug fixes - that is official position of ruby-core.
But TCS build will be released at the monday, which will be include this patches, (probably) backport of ruby-trunk's COW-friendly GC,
and improvements for Windows:

https://github.com/thecodeshop/ruby/wiki/FAQ#wiki-rbenv
https://github.com/thecodeshop/ruby/wiki/FAQ#wiki-rvm
https://github.com/thecodeshop/ruby/wiki/Downloads

You could make the argument that severely inefficient code is a bug. :/

What is "TCS build"?

Guess TCS stands for "The Code Shop" ;-)

Thanks for patching our beloved Ruby, so we can make love with it even faster!

@funny-falcon we need to find a way to provide equivalent patchlevels with rvm like: tcs-1.9.3-p125

Should this also work for 1.9.3-p125 by simply changing the p0 references or have these patches made it into the latest 1.9.3 release?

@jdutil , no, it will not. I will release updated patch as separate gist and will ask @burke to update this one.
And any way it will be available for rvm users as rvm install tcs

To run this on a recent rvm - which already knows p125 - and xcode 4.3's command_line_tools_for_xcode_.dmg installed, i.e. without gcc, you will need to change the line "rvm install..." to:

rvm install 1.9.3-p0 -n perf --patch $patchdir/falcon.patch --with-gcc=clang

Updated patch https://raw.github.com/gist/1859082/performance_and_backport_gc.patch - refer it appropriately.
@burke, could you update your recipe?

@luismreis no need to use --with-gcc=clang as of this commit on rvm head: https://github.com/wayneeseguin/rvm/commit/e075857769165ceafebcbafb6907291270f67ff9

@funny-falcon patch available in rvm head & stable as of this commit: https://github.com/wayneeseguin/rvm/commit/a0b0a660e7496243b35feebca47f344e9101c9ae

so to get ruby-1.9.3-p125-perf it is enough to write:

rvm get head
rvm install 1.9.3-perf --patch falcon

@mpapis, thank you :) you are blazingly fast! :)

1.9.3-perf built without issue on Mac OS X Lion after an rvm cleanup all.

What is required to get the debugger installed under -perf?

This is great thank you! How can we all get the ruby-core team to reconsider their position and add this to 1.9.3?

@funny-falcon : I changed the patch and bumped all the p0 references up to p125 -- thanks for the quick update!

@martinstreicher you should apply debug patch as well:

rvm remove 1.9.3-perf
rm -R ~/.rvm/src/ruby-1.9.3-p125-perf
rvm install 1.9.3-perf --patch falcon,debug

Also look up at https://gist.github.com/1688857#gistcomment-79449

I am guessing that 1.9.3-perf has the falcon patch already? On my machine, rvm install 1.9.3-perf --patch falcon,debug says 'falcon patch not found.' Let me try an rvm get head.

On Mon, Feb 20, 2012 at 9:07 AM, Martin Streicher
reply@reply.github.com
wrote:

I am guessing that 1.9.3-perf has the falcon patch already? On my machine, rvm install 1.9.3-perf --patch falcon,debug says 'falcon patch not found.'

Did you do "rvm get stable" before install?

Leonardo Mateo.
There's no place like ~

I tried once, then did rvm get head, then tried again, and things were happy.

On Feb 20, 2012, at 8:31 AM, Leonardo Mateo wrote:

On Mon, Feb 20, 2012 at 9:07 AM, Martin Streicher
reply@reply.github.com
wrote:

I am guessing that 1.9.3-perf has the falcon patch already? On my machine, rvm install 1.9.3-perf --patch falcon,debug says 'falcon patch not found.'

Did you do "rvm get stable" before install?

Leonardo Mateo.
There's no place like ~


Reply to this email directly or view it on GitHub:
https://gist.github.com/1688857

Im running OS X Lion 10.7.2 and I get rvm requires autoreconf to install the selected ruby interpreter however autoreconf was not found in the PATH.
I have Xcode command line tools installed but it seems there is no autoreconf on my system. Any ideas?

@tycooon I hope this helps: https://gist.github.com/1868805
autotools are not installed by the Xcode command line utils :(

I had to revert the gist to p0 because ruby-debug wouldn't compile under p125, even with pull request #47. I think it has to do with ruby_core_source fetching an incompatible version of the code. The error is an incompatible type for rb_iseq_compile_with_option at line 29 of ruby_debug.c on gem install ruby-debug.

I will try to dig into this at some point in the next few days, but if anyone has a quick fix I can apply, it would be appreciated.

Then you should also update the command to:
rvm get head && rvm install 1.9.3-p0-perf --patch falcon

I am also having issues with ruby-debug19 even after installing 1.9.3-p125 with --patch falcon,debug

Here's the output from Bundler..

Installing ruby-debug-base19 (0.11.25) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /Users/tom/.rvm/rubies/ruby-1.9.3-p125-perf/bin/ruby extconf.rb 
checking for rb_method_entry_t.body in method.h... no
checking for vm_core.h... no
/Users/tom/.rvm/gems/ruby-1.9.3-p125-perf@elocal/gems/ruby_core_source-0.1.5/lib/ruby_core_source.rb:39: Use RbConfig instead of obsolete and deprecated Config.
checking for rb_method_entry_t.body in method.h... no
checking for vm_core.h... no
Requesting http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz
Downloading http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz
checking for rb_method_entry_t.body in method.h... no
checking for vm_core.h... yes
checking for iseq.h... yes
checking for insns.inc... yes
checking for insns_info.inc... yes
checking for eval_intern.h... yes
creating Makefile

make
compiling breakpoint.c
compiling ruby_debug.c
ruby_debug.c:29: error: conflicting types for ‘rb_iseq_compile_with_option’
/Users/tom/.rvm/rubies/ruby-1.9.3-p125-perf/include/ruby-1.9.1/ruby-1.9.3-p125/vm_core.h:505: error: previous declaration of ‘rb_iseq_compile_with_option’ was here
ruby_debug.c: In function ‘call_at_line_unprotected’:
ruby_debug.c:480: warning: implicit conversion shortens 64-bit value into a 32-bit value
ruby_debug.c: In function ‘filename_cmp’:
ruby_debug.c:544: warning: implicit conversion shortens 64-bit value into a 32-bit value
ruby_debug.c:545: warning: implicit conversion shortens 64-bit value into a 32-bit value
ruby_debug.c: In function ‘debug_event_hook’:
ruby_debug.c:872: warning: implicit conversion shortens 64-bit value into a 32-bit value
ruby_debug.c: In function ‘optional_frame_position’:
ruby_debug.c:1732: warning: implicit conversion shortens 64-bit value into a 32-bit value
ruby_debug.c: In function ‘do_jump’:
ruby_debug.c:2346: warning: implicit conversion shortens 64-bit value into a 32-bit value
ruby_debug.c: In function ‘context_jump’:
ruby_debug.c:2414: warning: comparison between signed and unsigned
ruby_debug.c:2428: warning: comparison between signed and unsigned
make: *** [ruby_debug.o] Error 1


Gem files will remain installed in /Users/tom/.rvm/gems/ruby-1.9.3-p125-perf@elocal/gems/ruby-debug-base19-0.11.25 for inspection.
Results logged to /Users/tom/.rvm/gems/ruby-1.9.3-p125-perf@elocal/gems/ruby-debug-base19-0.11.25/ext/ruby_debug/gem_make.out
An error occured while installing ruby-debug-base19 (0.11.25), and Bundler cannot continue.
Make sure that `gem install ruby-debug-base19 -v '0.11.25'` succeeds before bundling.

p125 does not require the debug patch, I will remove it from rvm (for p125)

On Fri, Feb 24, 2012 at 5:47 PM, Tom Scott <
reply@reply.github.com

wrote:

I am also having issues with ruby-debug19 even after installing 1.9.3-p125
with --patch falcon,debug

Here's the output from Bundler..

Installing ruby-debug-base19 (0.11.25) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native
extension.

   /Users/tom/.rvm/rubies/ruby-1.9.3-p125-perf/bin/ruby extconf.rb

checking for rb_method_entry_t.body in method.h... no
checking for vm_core.h... no
/Users/tom/.rvm/gems/ruby-1.9.3-p125-perf@elocal/gems/ruby_core_source-0.1.5/lib/ruby_core_source.rb:39:
Use RbConfig instead of obsolete and deprecated Config.
checking for rb_method_entry_t.body in method.h... no
checking for vm_core.h... no
Requesting http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz
Downloading http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz
checking for rb_method_entry_t.body in method.h... no
checking for vm_core.h... yes
checking for iseq.h... yes
checking for insns.inc... yes
checking for insns_info.inc... yes
checking for eval_intern.h... yes
creating Makefile

make
compiling breakpoint.c
compiling ruby_debug.c
ruby_debug.c:29: error: conflicting types for rb_iseq_compile_with_option
/Users/tom/.rvm/rubies/ruby-1.9.3-p125-perf/include/ruby-1.9.1/ruby-1.9.3-p125/vm_core.h:505:
error: previous declaration of rb_iseq_compile_with_option was here
ruby_debug.c: In function call_at_line_unprotected:
ruby_debug.c:480: warning: implicit conversion shortens 64-bit value into
a 32-bit value
ruby_debug.c: In function filename_cmp:
ruby_debug.c:544: warning: implicit conversion shortens 64-bit value into
a 32-bit value
ruby_debug.c:545: warning: implicit conversion shortens 64-bit value into
a 32-bit value
ruby_debug.c: In function debug_event_hook:
ruby_debug.c:872: warning: implicit conversion shortens 64-bit value into
a 32-bit value
ruby_debug.c: In function optional_frame_position:
ruby_debug.c:1732: warning: implicit conversion shortens 64-bit value into
a 32-bit value
ruby_debug.c: In function do_jump:
ruby_debug.c:2346: warning: implicit conversion shortens 64-bit value into
a 32-bit value
ruby_debug.c: In function context_jump:
ruby_debug.c:2414: warning: comparison between signed and unsigned
ruby_debug.c:2428: warning: comparison between signed and unsigned
make: *** [ruby_debug.o] Error 1

Gem files will remain installed in
/Users/tom/.rvm/gems/ruby-1.9.3-p125-perf@elocal/gems/ruby-debug-base19-0.11.25
for inspection.
Results logged to /Users/tom/.rvm/gems/ruby-1.9.3-p125-perf@elocal
/gems/ruby-debug-base19-0.11.25/ext/ruby_debug/gem_make.out
An error occured while installing ruby-debug-base19 (0.11.25), and Bundler
cannot continue.
Make sure that gem install ruby-debug-base19 -v '0.11.25' succeeds
before bundling.


Reply to this email directly or view it on GitHub:
https://gist.github.com/1688857

@mpapis even with the debug patch removed, i still get this same error.

After installing this patched version in addition to improved performance I'm constantly getting this:

RAILS_ENV=test rake db:seed
[BUG] Segmentation fault
ruby 1.9.3p125 (2012-02-16) [x86_64-linux]
Segmentation fault

Running Ubuntu 11.10, x64, + rvm. Any ides why this is happening?

@vadim-v yeah, excuse me for that. I found a mistake at the time you were writing comment. I just fixed it at https://gist.github.com/1859082

Error happens only on very process exit finish, so I hope it were not so harmful.
I've made pull request to rvm with fix, hope it will be merged soon.

@funny-falcon Thanks for the fix, looking forward to see it merged.

had it merged few hours ago, it is available in rvm head

works fine for me now, thanks a lot

Awesome! Gives me 58-60% boost in startup time.

Before

time -p bundle exec rake environment
  real 6.81
  user 5.93
  sys 0.85

After

time -p bundle exec rake environment
  real 3.75
  user 2.82
  sys 0.91

I have about 280 gems in my Gemfile.lock and around 80 in Gemfile

@ralph thanks, that helped!

$ time bundle exec rspec -f d spec

====== ruby-1.9.2 =============================

Finished in 12.72 seconds
165 examples, 0 failures, 1 pending

real 0m47.060s
user 0m39.926s
sys 0m2.040s

====== ruby-1.9.3-p125-fast ===================

Finished in 6.71 seconds
165 examples, 0 failures, 1 pending

real 0m11.974s
user 0m11.009s
sys 0m0.904s

====== ruby-1.9.3-p125-fast + .bash_profile ===

Finished in 6.19 seconds
165 examples, 0 failures, 1 pending

real 0m11.601s
user 0m10.685s
sys 0m0.888s

Summary:
Real time: 4 times speedup!
.bash_profile: insignificant effect

@kedvictor if i am not completely lost, these patches will decrease the boot/load time of rails only. I bet that the 4 seconds you see is from rails boot.

I applied these patches and then compiled Ruby under Windows:

Before

sh-3.1$ time rails runner "puts"
real    0m52.477s
user    0m0.000s
sys     0m0.031s

After

sh-3.1$ time rails runner "puts"
real    0m24.150s
user    0m0.015s
sys     0m0.000s

@emerencia , if you work under Windows, you'd better look at TheCodeShop , it includes this patches, as well as some specifically targeted to Windows.

@funny-falcon Very nice, that's another 3 seconds faster for me:

sh-3.1$ time rails runner "puts"
real    0m20.320s
user    0m0.000s
sys     0m0.015s

Edit: and using Fenix takes off another 5 seconds:

real    0m15.472s
user    0m0.000s
sys     0m0.015s

I am having an issue when trying to compile some of that ruby debug hokey pokey. I will keep digging into it. (I have tried it with and without the debug patch)

rvm get head
rvm install 1.9.3-perf --patch falcon

gem install ruby-debug-base19-0.11.26.gem -- --with-ruby-include=$HOME/.rvm/src/ruby-1.9.3-p125-pref

Building native extensions. This could take a while...
ERROR: Error installing ruby-debug-base19-0.11.26.gem:
ERROR: Failed to build gem native extension.

    /Users/ttyrrell/.rvm/rubies/ruby-1.9.3-p125-perf/bin/ruby extconf.rb --with-ruby-include=/Users/ttyrrell/.rvm/src/ruby-1.9.3-p125-pref

checking for rb_method_entry_t.called_id in method.h... no
checking for rb_control_frame_t.method_id in method.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

mkmf.log:

have_struct_member: checking for rb_method_entry_t.called_id in method.h... -------------------- no

"/usr/bin/gcc-4.2 -o conftest -I/Users/ttyrrell/.rvm/rubies/ruby-1.9.3-p125-perf/include/ruby-1.9.1/x86_64-darwin11.3.0 -I/Users/ttyrrell/.rvm/rubies/ruby-1.9.3-p125-perf/include/ruby-1.9.1/ruby/backward -I/Users/ttyrrell/.rvm/rubies/ruby-1.9.3-p125-perf/include/ruby-1.9.1 -I. -I/Users/ttyrrell/.rvm/src/ruby-1.9.3-p125-pref -I/Users/ttyrrell/.rvm/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -fno-common -pipe conftest.c -L. -L/Users/ttyrrell/.rvm/rubies/ruby-1.9.3-p125-perf/lib -L/Users/ttyrrell/.rvm/usr/lib -L. -lruby.1.9.1 -lpthread -ldl -lobjc "
checked program was:
/* begin /
1: #include "ruby.h"
2:
3: int main() {return 0;}
/
end */

"/usr/bin/gcc-4.2 -I/Users/ttyrrell/.rvm/rubies/ruby-1.9.3-p125-perf/include/ruby-1.9.1/x86_64-darwin11.3.0 -I/Users/ttyrrell/.rvm/rubies/ruby-1.9.3-p125-perf/include/ruby-1.9.1/ruby/backward -I/Users/ttyrrell/.rvm/rubies/ruby-1.9.3-p125-perf/include/ruby-1.9.1 -I. -I/Users/ttyrrell/.rvm/src/ruby-1.9.3-p125-pref -I/Users/ttyrrell/.rvm/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -fno-common -pipe -c conftest.c"
conftest.c:3:20: error: method.h: No such file or directory
conftest.c:7: error: ‘rb_method_entry_t’ undeclared here (not in a function)
conftest.c:7: error: expected expression before ‘)’ token
checked program was:
/* begin /
1: #include "ruby.h"
2:
3: #include
4:
5: /*top
/
6: int main() {return 0;}
7: int s = (char )&((rb_method_entry_t)0)->called_id - (char )0;
/
end */


have_struct_member: checking for rb_control_frame_t.method_id in method.h... -------------------- no

"/usr/bin/gcc-4.2 -I/Users/ttyrrell/.rvm/rubies/ruby-1.9.3-p125-perf/include/ruby-1.9.1/x86_64-darwin11.3.0 -I/Users/ttyrrell/.rvm/rubies/ruby-1.9.3-p125-perf/include/ruby-1.9.1/ruby/backward -I/Users/ttyrrell/.rvm/rubies/ruby-1.9.3-p125-perf/include/ruby-1.9.1 -I. -I/Users/ttyrrell/.rvm/src/ruby-1.9.3-p125-pref -I/Users/ttyrrell/.rvm/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -fno-common -pipe -c conftest.c"
conftest.c:3:20: error: method.h: No such file or directory
conftest.c:7: error: ‘rb_control_frame_t’ undeclared here (not in a function)
conftest.c:7: error: expected expression before ‘)’ token
checked program was:
/* begin /
1: #include "ruby.h"
2:
3: #include
4:
5: /*top
/
6: int main() {return 0;}
7: int s = (char )&((rb_control_frame_t)0)->method_id - (char )0;
/
end */


@timtyrrell Seems like you have typo in last word:

gem install ruby-debug-base19-0.11.26.gem -- --with-ruby-include=$HOME/.rvm/src/ruby-1.9.3-p125-pref

should be '...-p125-perf'
and not '...-p125-pref'

@vadim-v you were right! Works now :)

@burke , I've updated https://gist.github.com/1859082 so that ruby-debug19 now compiles (rb_iseq_compile_with_option was my fault: I've touch Changelog, which forces revision.h to be overwritten, that forces ruby-debug to assume wrong ruby version) . Could you check it?

@funny-falcon awesome! I'll try it out and update my gist this afternoon. Thanks!

On my system (which has Xcode 4.3 and the new separate Xcode command line tools package installed), kastiglione's fork worked for me, and not this one (I'm fairly certain this is because he omits require_gcc from his ruby build script; gcc isn't installed by the command line tools package, and instead is linked to llvm. 1.9.3-p125 is the first Ruby release to officially support LLVM instead of just clang).

@kreeg, be careful, 1.9.3-p125 was claimed to be supported with LLVM - but still magic errors appear and things might fail randomly. I heard situation has proven for 1.9.3-head.

@mpapis Yuck. Thanks for the heads-up, I'll keep an eye out.

Does 1.9.3-head have the -perf patches available?

On Mar 22, 2012, at 11:34 AM, Michal Papis wrote:

@kreeg, be careful, 1.9.3-p125 was claimed to be supported with LLVM - but still magic errors appear and things might fail randomly. I heard situation has proven for 1.9.3-head.


Reply to this email directly or view it on GitHub:
https://gist.github.com/1688857

@martinstreicher no there is no yet, but the one from p125 should work fine (@funny-falcon any news for the patch?):

rvm install 1.9.3-head --patch $rvm_path/patches/ruby/1.9.3/p125/falcon.patch -j 3

@mpapis, I'm busy at new work a bit, but I'll try to sync all my patches at weekend.

Almost.

[2012-03-22 12:34:07] patch -F 25 -p1 -N -f <"//Users/strike/.rvm/patches/ruby/1.9.3/p125/falcon.patch"
patching file Changelog.backport_gc
patching file class.c
patching file common.mk
patching file compile.c
patching file configure.in
Hunk #1 succeeded at 1315 (offset 2 lines).
Hunk #2 succeeded at 1439 (offset 2 lines).
patching file debug.c
patching file dln.c
patching file dln_find.c
patching file ext/dl/cfunc.c
patching file ext/readline/readline.c
patching file ext/syck/emitter.c
patching file ext/syck/rubyext.c
patching file ext/syck/syck.c
patching file ext/syslog/syslog.c
patching file gc.c
Hunk #13 succeeded at 519 with fuzz 3.
Hunk #14 succeeded at 533 (offset -1 lines).
Hunk #15 succeeded at 902 (offset -1 lines).
Hunk #16 succeeded at 975 (offset -1 lines).
Hunk #17 succeeded at 1105 (offset -1 lines).
Hunk #18 succeeded at 1238 (offset -1 lines).
Hunk #19 succeeded at 1256 (offset -1 lines).
Hunk #20 succeeded at 1323 (offset -1 lines).
Hunk #21 succeeded at 1346 (offset -1 lines).
Hunk #22 succeeded at 1367 (offset -1 lines).
Hunk #23 succeeded at 1547 (offset -1 lines).
Hunk #24 succeeded at 1578 (offset -1 lines).
Hunk #25 succeeded at 1641 (offset -1 lines).
Hunk #26 succeeded at 1655 (offset -1 lines).
Hunk #27 succeeded at 1673 (offset -1 lines).
Hunk #28 succeeded at 1683 (offset -1 lines).
Hunk #29 succeeded at 1698 (offset -1 lines).
Hunk #30 succeeded at 1751 (offset -1 lines).
Hunk #31 succeeded at 1764 (offset -1 lines).
Hunk #32 succeeded at 1783 (offset -1 lines).
Hunk #33 succeeded at 1796 (offset -1 lines).
Hunk #34 succeeded at 1818 (offset -1 lines).
Hunk #35 succeeded at 1853 (offset -1 lines).
Hunk #36 succeeded at 1861 (offset -1 lines).
Hunk #37 succeeded at 2125 (offset -1 lines).
Hunk #38 succeeded at 2146 (offset -1 lines).
Hunk #39 succeeded at 2173 (offset -1 lines).
Hunk #40 succeeded at 2201 (offset -1 lines).
Hunk #41 succeeded at 2290 (offset -1 lines).
Hunk #42 succeeded at 2304 (offset -1 lines).
Hunk #43 succeeded at 2312 (offset -1 lines).
Hunk #44 succeeded at 2349 (offset -1 lines).
Hunk #45 succeeded at 2361 (offset -1 lines).
Hunk #46 succeeded at 2411 (offset -1 lines).
Hunk #47 succeeded at 2446 (offset -1 lines).
Hunk #48 FAILED at 2649.
Hunk #49 succeeded at 2821 (offset -23 lines).
Hunk #50 succeeded at 2829 (offset -23 lines).
Hunk #51 succeeded at 2852 (offset -23 lines).
Hunk #52 succeeded at 3096 (offset -23 lines).
Hunk #53 succeeded at 3125 (offset -23 lines).
Hunk #54 succeeded at 3144 (offset -23 lines).
Hunk #55 succeeded at 3162 (offset -23 lines).
Hunk #56 succeeded at 3218 with fuzz 2 (offset -23 lines).
Hunk #57 succeeded at 3247 (offset -23 lines).
Hunk #58 succeeded at 3283 (offset -23 lines).
Hunk #59 succeeded at 3291 (offset -23 lines).
Hunk #60 succeeded at 3369 (offset -23 lines).
Hunk #61 succeeded at 3442 (offset -23 lines).
Hunk #62 succeeded at 3485 (offset -23 lines).
Hunk #63 succeeded at 3496 (offset -23 lines).
Hunk #64 succeeded at 3505 (offset -23 lines).
Hunk #65 succeeded at 3604 (offset -23 lines).
Hunk #66 succeeded at 3659 (offset -23 lines).
Hunk #67 succeeded at 3878 (offset -23 lines).
1 out of 67 hunks FAILED -- saving rejects to file gc.c.rej
patching file include/ruby/ruby.h

On Mar 22, 2012, at 12:17 PM, Michal Papis wrote:

@martinstreicher no there is no yet, but the one from p125 should work fine (@funny-falcon any news for the patch?):

rvm install 1.9.3-head --patch $rvm_path/patches/ruby/1.9.3/p125/falcon.patch -j 3


Reply to this email directly or view it on GitHub:
https://gist.github.com/1688857

That would be because the method to patch is no longer there:

Wed Feb 22 08:11:06 2012 Narihiro Nakamura authornari@gmail.com

* gc.c : remove gc_clear_mark_on_sweep_slots() and use
  rest_sweep() instead of it, because some dead objects might be
  marked in next the mark phase by false pointers.
  [ruby-core:42672]

For those still having trouble with ruby-debug19, check out @cldwalker's fork (renamed to debugger). I'm using it with the falcon patchset.

https://github.com/cldwalker/debugger

@funny-falcon any chance for your patch for the official 1.9.3-p194?

Please don't use https://github.com/ruby/ruby/pull/47.diff any more, instead substitute ruby-debug19 with debugger per @jeremyw's suggestion.

@pjg, yes, I'll form it at weekend. In fact, it is in http://github.com/thecodeshop/ruby repository. tcs-ruby_1_9_3 branch contains all peaces united as well as other (not mine) patches which affect performance on Windows platform.
But ultrapacking (for hashes of size 1) isn't there yet. I'll add it at weekend and publish patch then.

@funny-falcon great! Thank you very much!

Please let us know how to install with rvm when it's released/

On Apr 27, 2012, at 3:36 AM, Paweł Gościcki wrote:

@funny-falcon great! Thank you very much!


Reply to this email directly or view it on GitHub:
https://gist.github.com/1688857

The debugger gem works well with 1.9.3.

On Apr 26, 2012, at 10:01 PM, Samuel Cochran wrote:

Please don't use https://github.com/ruby/ruby/pull/47.diff any more, instead substitute ruby-debug19 with debugger.


Reply to this email directly or view it on GitHub:
https://gist.github.com/1688857

https://gist.github.com/2593385

curl https://raw.github.com/gist/2593385/perf_and_gc.diff > perf_and_gc.diff
rvm install 1.9.3-falcon --patch ./perf_and_gc.diff -j 3

it's now in RVM:

rvm get head && rvm reinstall 1.9.3-p194 --patch falcon

or:

rvm get stable && rvm reinstall 1.9.3-p194 --patch falcon

Wow, it is even faster than p125-perf.

@sekrett, it could be possibly because plain ruby-p194 faster than p125, this patch remains almost same.

@mpapis, thank you.

Thank you!!!

On May 4, 2012, at 6:30 PM, Michal Papis wrote:

it's now in RVM:

rvm get head && rvm reinstall 1.9.3-p194 --patch falcon

or:

rvm get stable && rvm reinstall 1.9.3-p194 --patch falcon


Reply to this email directly or view it on GitHub:
https://gist.github.com/1688857

@funny-falcon this is excellent in my dev environment, thanks! Now is there a method for installing it without rbenv or rvm? I'd like to try it out in a production environment where I use a straight Ruby build without rbenv or rvm.

Here you find a script to install it without using rbenv or rvm: https://gist.github.com/1830994

You may need to update it to the latest version.

I ended up figuring it out, and wrote a Sprinkle package:

package :ruby193_falcon do
  description "Ruby Virtual Machine"
  version "1.9.3"

  install_steps = [
    "cd /usr/local/build/ruby-1.9.3-p194 && AUTOCONF=/usr/bin/autoconf ./configure > ruby193_falcon-configure.log 2>&1",
    "cd /usr/local/build/ruby-1.9.3-p194 && AUTOCONF=/usr/bin/autoconf make > ruby193_falcon-build.log 2>&1",
    "cd /usr/local/build/ruby-1.9.3-p194 && AUTOCONF=/usr/bin/autoconf make install > ruby193_falcon-install.log 2>&1"
  ]

  source "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz", custom_install: install_steps do
    pre :configure, "wget https://raw.github.com/wayneeseguin/rvm/master/patches/ruby/1.9.3/p194/falcon.diff && patch -p1 < falcon.diff > ruby193_falcon-patch.log 2>&1"
    post :install, "gem update --system"
  end

  requires :ruby_deps

  verify do
    has_executable "ruby"
  end
end

@cvincent Consider adding https://gist.github.com/2981959 to your package: that patch could smooths EventMachin's performance a bit under high load.

@funny-falcon Yeah it looks like "Array as queue" performance improvements would be helpful in general. I know that I certainly use methods like #push, #pop, and #shift all the time. Thanks for all your work on these patches! The improvements in boot time have brought much joy to my day-to-day.

Wow, I totally forgot about this gist. Sorry, I've updated it for p194 now. Thanks again for the patches :)

why do we need require_gcc for 1.9.3p-194 in rbenv?

The RVM recipe worked perfectly for me. Thanks for keeping it updated.

How can we help get this pulled into the master branch?

mountain lion + xcode4.4.1 + brew install autoconf + remove require_gcc == win

Thanks @samgranieri and @julian7, I forgot that line was in there. I've updated the gist.

I would change the 'install XCode' to reference the Command Line Tools instead. See my fork here: https://gist.github.com/3453141/76972c7185b579f5542d12cf56eae8d068c908ca

This patch is available in rvm stable, so if you don't want to live on the edge you can do rvm get stable instead.

@burke I think you should update your instructions to use RVM stable rather than head, because the patch is already available in RVM stable and at the moment head seems quite unstable. It took me lots of digging and trial and error until I figured that I failed to compile Ruby with this patch because I was on the head version rather stable.

VERY cool! Here are my before stats, the base 1.9.3-p194:

mwhalen at Ajax in ~/Sites/askherzl on master!
± time rails r "puts 1"
Connecting to database specified by database.yml
1
rails r "puts 1"  4.23s user 1.19s system 54% cpu 10.009 total

And here is the same command after installing the patch, adding the suggested lines to my ~/.zshrc and re-running bundle:

mwhalen at Ajax in ~/Sites/askherzl on master!
± time rails r "puts 1"
Connecting to database specified by database.yml
1
rails r "puts 1"  2.95s user 0.90s system 58% cpu 6.549 total

That's pretty much an exact 35% increase in performance. Installing gem's feels a great deal quicker as well.

Any idea why execution would actually be slower with this patch? Using RVM on a retina MBP:

ruby-1.9.3-p194:

$ time rails runner 'puts 3'
real    0m7.454s
user    0m6.481s
sys 0m0.957s

ruby-1.9.3-p194-perf:

$ time rails runner 'puts 3'
real    0m12.410s
user    0m11.347s
sys 0m1.036s

ruby-1.9.3-p194-perf with exports

$ time rails runner 'puts 3'
real    0m9.609s
user    0m8.344s
sys 0m1.250s

@dvandersluis
the same with you.

Should we be using falcon's new patch now?

I tried benchmarking falcon's new patch on top of vanilla 1.9.3-p194 against 1.9.3-p194-perf: (using avgtime):

$ rvm current && avgtime -q -r5 -d -p rails runner "puts 1"
ruby-1.9.3-p194-perf

------------------------
Total time (ms): 46419.8
Repetitions    : 5
Sample mode    : 9320 (1 ocurrences)
Median time    : 9282.5
Avg time       : 9283.95
Std dev.       : 23.6096
Minimum        : 9257.65
Maximum        : 9321.53
95% conf.int.  : [9237.68, 9330.23]  e = 46.2739
99% conf.int.  : [9223.14, 9344.77]  e = 60.8142
EstimatedAvg95%: [9263.26, 9304.65]  e = 20.6943
EstimatedAvg99%: [9256.76, 9311.15]  e = 27.1969
Sorted times   : 
    [9257.65, 9261.26, 9282.5, 9296.83, 9321.53]

$ rvm current && avgtime -q -r5 -d -p rails runner "puts 1"
ruby-1.9.3-p194-falcon-new

------------------------
Total time (ms): 35149.3
Repetitions    : 5
Sample mode    : 6970 (2 ocurrences)
Median time    : 7032.1
Avg time       : 7029.87
Std dev.       : 52.5191
Minimum        : 6970.93
Maximum        : 7113.02
95% conf.int.  : [6926.93, 7132.8]  e = 102.936
99% conf.int.  : [6894.59, 7165.15]  e = 135.28
EstimatedAvg95%: [6983.83, 7075.9]  e = 46.0342
EstimatedAvg99%: [6969.37, 7090.37]  e = 60.4991
Sorted times   : 
    [6970.93, 6977.6, 7032.1, 7055.69, 7113.02]

There are some issues w/ RVM when installing these. If you rename the ruby (by calling it 1.9.3-perf) or whatever, it won't include the cflags patch. So you'll actually lose quite a bit of performance doing this. Be sure to include --patch cflags.patch Also it is best to include --disable-shared

kewl! will surely test it when I get home. Thanks for hard work.

kewl! will surely test it when I get home. Thanks for hard work.

BUILD FAILED

Inspect or clean up the working tree at /var/folders/50/nmb34mx94js1fd1z_s5fl8pr0000gn/T/ruby-build.20121130224625.6476
Results logged to /var/folders/50/nmb34mx94js1fd1z_s5fl8pr0000gn/T/ruby-build.20121130224625.6476.log

Last 10 log lines:
ossl_x509store.c:520: warning: ‘X509_STORE_CTX_set_flags’ is deprecated (declared at /usr/include/openssl/x509_vfy.h:464)
ossl_x509store.c: In function ‘ossl_x509stctx_set_purpose’:
ossl_x509store.c:532: warning: ‘X509_STORE_CTX_set_purpose’ is deprecated (declared at /usr/include/openssl/x509_vfy.h:460)
ossl_x509store.c: In function ‘ossl_x509stctx_set_trust’:
ossl_x509store.c:544: warning: ‘X509_STORE_CTX_set_trust’ is deprecated (declared at /usr/include/openssl/x509_vfy.h:461)
ossl_x509store.c: In function ‘ossl_x509stctx_set_time’:
ossl_x509store.c:561: warning: ‘X509_STORE_CTX_set_time’ is deprecated (declared at /usr/include/openssl/x509_vfy.h:466)
linking shared-object dl/callback.bundle
linking shared-object openssl.bundle
make: *** [build-ext] Error 2

Mother of God...

Running this patch against p327 is working. I'm running RVM. Here are my steps (pretty simple):

brew install autoconf automake
curl https://raw.github.com/gist/4136373/falcon-gc.diff > $rvm_path/patches/ruby/1.9.3/p327/falcon.patch
rvm install 1.9.3-p327 -n fast --patch falcon

Then recreate my gemsets and bundle of course.

Benchmarks?

p286:

time rake
...
real    0m48.761s
user    0m41.117s
sys     0m3.561s

time rails runner puts 'foobar'
....
real    0m4.939s
user    0m4.210s
sys     0m0.719s

p327 + patch:

time rake
...
real    0m20.775s
user    0m15.543s
sys     0m2.208s

time rails runner puts 'foobar'
...
real    0m2.610s
user    0m2.047s
sys     0m0.553s

Greatest patch ever!!

This is really great. I ran a few benchmarks against 2 separate apps. We're seeing a 28% - 49% speed increase depending on the test!

The rbenv installation gets build failures on Mountain Lion:

~Code/goodbre.ws master % curl https://raw.github.com/gist/1688857/rbenv.sh | sh ; rbenv global 1.9.3-p327-perf
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   138  100   138    0     0    180      0 --:--:-- --:--:-- --:--:--   467
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   448  100   448    0     0   1194      0 --:--:-- --:--:-- --:--:--  1539
Downloading yaml-0.1.4.tar.gz...
-> http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz
Installing yaml-0.1.4...
Installed yaml-0.1.4 to /Users/david/.rbenv/versions/1.9.3-p327-perf

Downloading ruby-1.9.3-p327.tar.gz...
-> http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p327.tar.gz
Installing ruby-1.9.3-p327...

BUILD FAILED

Inspect or clean up the working tree at /var/folders/tt/0zgjrcdd4zn0pvfmmp4s9n600000gq/T/ruby-build.20121206132529.63012
Results logged to /var/folders/tt/0zgjrcdd4zn0pvfmmp4s9n600000gq/T/ruby-build.20121206132529.63012.log

Last 10 log lines:
ossl_x509store.c: In function ‘ossl_x509stctx_set_flags’:
ossl_x509store.c:520: warning: ‘X509_STORE_CTX_set_flags’ is deprecated (declared at /usr/include/openssl/x509_vfy.h:464)
ossl_x509store.c: In function ‘ossl_x509stctx_set_purpose’:
ossl_x509store.c:532: warning: ‘X509_STORE_CTX_set_purpose’ is deprecated (declared at /usr/include/openssl/x509_vfy.h:460)
ossl_x509store.c: In function ‘ossl_x509stctx_set_trust’:
ossl_x509store.c:544: warning: ‘X509_STORE_CTX_set_trust’ is deprecated (declared at /usr/include/openssl/x509_vfy.h:461)
ossl_x509store.c: In function ‘ossl_x509stctx_set_time’:
ossl_x509store.c:561: warning: ‘X509_STORE_CTX_set_time’ is deprecated (declared at /usr/include/openssl/x509_vfy.h:466)
linking shared-object openssl.bundle
make: *** [build-ext] Error 2

Looks like the problem was that my CONFIGURE_OPTS weren't getting picked up. If you're getting build failures on OSX, install it with the following so that it gets compiled correctly with support for the right OpenSSL and Readline libs:

brew install openssl readline
curl https://raw.github.com/gist/1688857/2-$VERSION-patched.sh > /tmp/1.9.3-p327-perf
CONFIGURE_OPTS="--with-openssl-dir=`brew --prefix openssl` --with-readline-dir=`brew --prefix readline`" rbenv install /tmp/1.9.3-p327-perf

Boy I sure wish that gist comments were editable. That should have been:

brew install openssl readline
curl https://raw.github.com/gist/1688857/2-1.9.3-p327-patched.sh > /tmp/1.9.3-p327-perf
CONFIGURE_OPTS="--with-openssl-dir=`brew --prefix openssl` --with-readline-dir=`brew --prefix readline`" rbenv install /tmp/1.9.3-p327-perf

Is this patch still relevant for 1.9.3-p362?

As expected applying it to p362 doesn't work.

I got issues when compiling, and I would see this:

checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: C compiler cannot create executables

I tracked down the issue to the "-march=native"-flag. When removed or changed to "-march=nocona" (on my Late 2008 Macbook with a Intel Core 2 Duo running Mountain Lion) it worked just fine.

I hope others won't hit this bug by reading this, because it has costed me some time tracking it down.

Mountain Lion+RVM users follow instructions by @cannikin.

And if you are getting Error running 'make ' you might have to append --with-gcc=gcc so the line looks like: `rvm install 1.9.3-p327 -n fast --patch falcon --with-gcc=gcc

ruby-build has S3-based mirrors for the various dependencies, which you can make use of in this gist, for times when sites like pyyaml.org go down.

To do so, change line 14 and 15 of 2-1.9.3-p327-patched.sh to be:

install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz#36c852831d02cf90508c29852361d01b"
install_package "ruby-1.9.3-p327" "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p327.tar.gz#96118e856b502b5d7b3a4398e6c6e98c" combined_patch

(I'm simply pulling these out of ruby-build's relevant manifest files here.)

That will attempt to download from the source and then fall-back to the S3 mirror if needed.

This hasn't been touched in a while, but with the new gist links, things will likely break. I've made a version of the rbenv definition file that should work, for the time being.
https://gist.github.com/umtrey/7592062

To get rid of the following error:

regparse.c:582:15: error: implicit conversion loses integer precision: 'st_index_t' (aka 'unsigned long') to 'int' [-Werror,-Wshorten-64-to-32]

In addition to https://gist.github.com/umtrey/7592062, I had to do the following first

brew update
brew tap homebrew/dupes
brew install apple-gcc42
export CC=gcc-4.2

Then rbenv install /tmp/1.9.3-p327-perf

Thanks @m-shirshendu! That did the trick.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.