Rubinius
 1.0 and more!
X
Phoeni

             factors
Rubinius
  Much more!
1.0
  Finally out!


12,206 commits
1.0
1.8.7 compatible
1.0
Good Performance
1.0
  Good Performance
20x faster than MRI sometimes
1.0
Good Performance
10x slower in sometimes
1.0
Good Performance
   Tools to help
Rubinius
  Why bother?
Rubinius
  Dogfood
Rubinius
 Ruby is currency
Rubinius
  C is opaque
Rubinius
 JIT loves Ruby
DataMapper
  Now Supported!
DataMapper
  Now Supported!
Information
Geographics
   Now Supported!
NfoG
Now Supported!
o/~ Data in your maps yo.
   Information Geo. o/~
NotImplementedError
NotImplementedError
Implemented
Implemented
 ObjectSpace
Implemented
 ObjectSpace
    _id2ref
Implemented
 ObjectSpace
  _id2ref - Slow
Implemented
   ObjectSpace
_id2ref - Searches Heap
Implemented
 ObjectSpace
  each_object
Implemented
          ObjectSpace
find_object([:kind_of, what], block)
Implemented
 ObjectSpace
 More Powerful API
Performance
   A “Hot” Topic
Performance
   Measure
Performance
       Measure
Measure, measure, measure
Performance
     Measure
  Benchmark.measure
Performance
    Measure
  -Xprofile (1.0.1)
Performance
      Measure
 Sampling Profiler (1.1)
Performance
   Measure
    Demo
Debugger
 New / Old Feature
Debugger
 Inspect code
Debugger
 Inspect Code
   Code Split
Debugger
 Inspect Code
  VM integration
CompiledMethod#set_breakpoint

 Thread#set_debugger_thread

     Location#variables
Debugger
 Inspect Code
   debugger.rb
Debugger
 Inspect Code
 Write your own!
Memory Profiler

     (1.1)
Memory
C-API hooks
Memory
   C-API hooks
Write a memory profiler
Query Agent
   Know thy self
Query Agent
 know thy self
    VM API
Query Agent
  know thy self
Export VM internal data
Query Agent
   know thy self
Invaluable debugging tool
Query Agent
 know thy self
     Demo
Compliance
      C-API
 syck, nokogiri, etc.
Compliance
     C-API
  A few gotchas...
C Extension
Do’s and Don’ts
Do
prefer a function over an
       R*() macro
Rubinius




RBASIC(obj)->class

rb_obj_class(obj)
1.9 / Rubinius




ROBJECT(obj)->iv_tbl

rb_ivar_[get|set](obj, ...)
1.9 / Rubinius




      Don’t
use the “re.h” header
1.9 / Rubinius




           Don’t
use the “env.h” header
 ruby_frame    ruby_dyna_vars
 ruby_scope     ruby_in_eval
  ruby_class
Try your gem
Report your
 problems!
http://github.com/
evanphx/rubinius/
       issues
Performance
Performance
 The Two Fronts
Performance
  Why We Fight
   What We Write
(0..10).to_a.each do |i|
 ary << i
end
0.upto(10) do |i|
 ary << i
end
Performance
 The Two Fronts
  How We Run It
Performance
  Benchmarking
Performance
   Benchmarking
 Expectations vs. Reality
Performance
      Benchmarking
Lies, Damned Lies, and Statistics
Benchmarks
114
      Times faster than 1.8
100



 86



 71



 57



 43



 29



 14



  0

               ruby 1.9       jruby   macruby   rubinius
57
     Times faster than 1.8
50



43



36



29



21



14



 7



 0

              ruby 1.9       jruby   macruby   rubinius
impl       1.8      1.9    jruby    macruby    rbx



  ms       309304   51113   113824   70580     24232



x faster    1.0      6.0     2.7       4.3     12.7
Benchmarks
  12x faster!
Benchmarks
    12x faster!
 On these benchmarks!
Benchmarks
  12x faster!
   In general?
Benchmarks
What did we benchmark?
Calling a method.
Empty while loop.
Creating a block.
Accessing ivars.

             Performing ‘not’.
     Calling a polymorphic method.
              Calling super.
Benchmarks
 Why these things?
Benchmarks
   Why these things?
How do these results translate?
Analogy
Dishonest?
Rubinius
Ruby performance
      begets
core performance
1.8
Ruby performance
      begets
        ?
Benchmarks
Need more/better data
def foo()
  ary = []
  100.times { |i| ary << i }
end




                          300,000
                           times
Seconds

8
    7.82




6




4                   4.24
           3.91

                                    3.26

                            2.60
2




0
    1.8    1.9    macruby   jruby   rbx
def foo()
  hsh = {}
  100.times { |i| hsh[i] = 0 }
end




                          100,000
                           times
Seconds
 11
                                      10.5




8.25

                      7.62




 5.5

       4.77   4.7



2.75


                              1.67


  0
       1.8    1.9   macruby   jruby   rbx
def foo()
  hsh = { 47 => true }
  100.times { |i| hsh[i] }
end




                        100,000
                         times
Seconds

4

    3.64



3


                    2.61            2.6


2          2.12

                            1.75



1




0
    1.8    1.9    macruby   jruby   rbx
Benchmarking
   Conclusion
Benchmarking
        Conclusion
Rubinius is awesome at ruby code
Benchmarking
      Conclusion
 Comparing C/Java to Ruby
More Ruby
More Ruby
Burden of our own devising
More Ruby
 Fast compliance
More Ruby
Slower core performance
More Ruby
Slower core performance
      Ruby vs. C/Java
More Ruby
 The upside...
114
      Times faster than 1.8
100



 86



 71



 57



 43



 29



 14



  0

               ruby 1.9       jruby   macruby   rubinius
114
      Times faster than 1.8
100



 86



 71



 57



 43



 29



 14



  0

               ruby 1.9       jruby   macruby   rubinius
def m; nil; end
def Bench.run
 i=0
 while i < 15_000_000
   i+=1
   m; m; m; m; m; m; m; m
 end
end
impl       1.8    1.9    jruby   macruby   rbx



  ms       21361   6316   10101    3295     186



x faster    1.0    3.4     2.1      6.5     114.8
impl       1.8    1.9    jruby   macruby    rbx



  ms       21361   6316   10101    3295      186



x faster    1.0    3.4     2.1      6.5     114.8
impl       1.8    1.9    jruby   macruby   rbx



  ms       21361   6316   10101    3295     186



x faster    1.0    3.4     2.1      6.5
                                          114.8
impl       1.8    1.9    jruby   macruby   rbx



  ms       21361   6316   10101    3295     186



x faster    1.0    3.4     2.1
                                  114.8
                                    6.5
impl       1.8    1.9    jruby   macruby   rbx



  ms       21361   6316   10101    3295     186



x faster    1.0    3.4
                          114.8
                           2.1      6.5
impl       1.8    1.9    jruby   macruby   rbx




  114.8
  ms       21361   6316   10101    3295     186



x faster    1.0    3.4     2.1      6.5
Bug
Bug
right?
Bug
def m; nil; end
def Bench.run
  i=0
  while i < 15_000_000
    i+=1
    m; m; m; m; m; m; m; m
  end
end
Year 4
     JIT
Method Inlining
def m; nil; end
def Bench.run
  i=0
  while i < 15_000_000
    i+=1
    m; m; m; m; m; m; m; m
  end
end
bin/rbx
  -Xjit.inline.debug
  0/bm_vm2_method.rb
JIT: compiling Object#run
inlining: primitive fixnum_lt into run.
inlining: Object#m into run (<metaclass>)
inlining: Object#m into run (<metaclass>)
inlining: Object#m into run (<metaclass>)
inlining: Object#m into run (<metaclass>)
inlining: Object#m into run (<metaclass>)
inlining: Object#m into run (<metaclass>)
inlining: Object#m into run (<metaclass>)
inlining: Object#m into run (<metaclass>)
def m; nil; end
def Bench.run
  i=0
  while i < 15_000_000
    i+=1
nil;nil;nil;nil;nil;nil;nil;nil
  end
end
def m; nil; end
def Bench.run
  i=0
  while i < 15_000_000
    i+=1
  end
end
Performance
Performance
Many programs, much faster
Performance
Many programs, a little slower
Performance
Some programs, a lot slower
Releases
Releases
  0.13
Releases
    0.13
 JIT by default
Releases
    0.13
 Lots of fixes
1.0rc1
Next Week!
Expectations
Expectations
   Runs rails 3
Expectations
Performance improvements
Expectations
One RC every month
Expectations
One RC every month
    Until 1.0 is out.

Rubinius 1.0 and more!