ruby-build: ruby-build built ruby is slow
I have a new 15" Retina MacBook Pro (Early 2013) that I have installed numerous rubies on via rbenv and ruby-build. These rubies work just fine, but they are very slow. To illustrate, I created the following ruby script:
require 'benchmark'
array = (1..1000000).map { rand }
puts Benchmark.measure { array.dup.sort }
I then ran the benchmark on multiple rubies:
# System Ruby (1.8.7)
➜ time /usr/bin/ruby bm.rb
1.470000 0.010000 1.480000 ( 1.478272)
/usr/bin/ruby bm.rb 1.71s user 0.02s system 99% cpu 1.740 total
# rbenv/ruby-build installed ruby 2.0.0
➜ time ~/.rbenv/versions/2.0.0-p0/bin/ruby bm.rb
2.770000 0.010000 2.780000 ( 2.746690)
~/.rbenv/versions/2.0.0-p0/bin/ruby bm.rb 3.14s user 0.03s system 99% cpu 3.173 total
# homebrew installed ruby 2.0.0
➜ time /usr/local/bin/ruby bm.rb
0.990000 0.010000 1.000000 ( 0.989383)
/usr/local/bin/ruby bm.rb 1.15s user 0.03s system 99% cpu 1.185 total
That is, Ruby 2.0 built via ruby-build is more than 2.5 times slower than the same ruby built with homebrew and ialmost twice as slow as the system installed ruby 1.8.7.
GCC is present and accounted for:
➜ which gcc
/usr/bin/gcc
➜ gcc --version
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
I’m really interested in figuring out what’s going on here, but I don’t know what to look at next. Has anyone seen this before? What can I look at next?
About this issue
- Original URL
- State: closed
- Created 11 years ago
- Comments: 18 (16 by maintainers)
@dunric Glad your hair is still intact. It is a pain. We solved a clang issue by setting a
-Wflag, but that clears Ruby’s default flags. One step forward; two steps back! Please do dig in and lend a hand 😁