Improving the Rails
    ecosystem
   The Rubinius Virtual Machine




                1
Thanks EY!




    2
Be thinking of questions
a_better_ruby
     ==
a_better_rails
             # => true
Brand new code base
Write in ruby first.
       Then C if you have to.
If you’re not failing every now
and again, it’s a sign you’re not
doing anything very innovative.
                   Woody...
A work in progrees
Nov. 3: 1.0 preview
  End of 07: 1.0
You’re the customer
Help me help you.
Tell me your pain.
Some current pain
Memory usage


               Memory
• 1.8 garbage collector is simple, but too simple.
• Rubinius uses modern techniques to decrease
  memory usage and increa...
The forking problem


                      Memory
In 1.8...

• Start up a mongrel.
• Require all your code.
• fork() the process.
• Watch your memory double.

             ...
In Rubinius...

• Start up a mongrel.
• Require all your code.
• fork() the process.
• Watch NO change in the memory footp...
Memory change per
          additional mongrel instance




1          2               3            4

    1.8            ...
Packaging / Deployment
.rba == .jar
.rba == .war


                Packaging
• Precompiled code (.rbc)
• Meta data about project
  • RDoc
• Assets

                            Packaging
             ...
Performance
Built for change


                   Performance
Modern Techniques


• Inline caching
• Pre-compiled code
• JIT (eventually)

                           Performance
      ...
3 legged dog   turtles        space shuttle   rubinius
                                                Performance
       ...
Error reporting
Normal Backtraces

    An exception has occurred:
        User requested termination with Control-C (Interrupt)

    Backt...
C extensions can
               misbehave


Reporting
VALUE test_segfault(VALUE self) {
                                // Get a pointer to address 4.
                         ...
Time lost to segfaults
                         (in minutes)


                   1.8                      rubinius
      ...
Profiling
In 1.8...


• Profiling is instrumented only.
• The speed hit is prohibitive for running in
  production mode



          ...
In Rubinius...


• Sampling profiler available always
• Has little to no impact on performance


                          ...
In my_app.rb
           require ‘simple_profile’

           profile(:profile1) do
             obj.run_slow_method
      ...
In environment.rb
      require ‘simple_profile’

      SimpleProfiler.profile_actions
      SimpleProfiler.profile_views
...
Disclaimer
• All statements and numbers and opinions are
  only those of Evan Phoenix.

• All statistics are made up, but represent a...
Evan Phoenix
    evan@fallingsnow.net
  ephoenix@engineyard.com




             39
Upcoming SlideShare
Loading in …5
×

Rubinius - Improving the Rails ecosystem

6,671 views
6,609 views

Published on

A talk on Rubinius at RailsConf Europe 2007.

Published in: Business, Technology
1 Comment
1 Like
Statistics
Notes
No Downloads
Views
Total views
6,671
On SlideShare
0
From Embeds
0
Number of Embeds
27
Actions
Shares
0
Downloads
152
Comments
1
Likes
1
Embeds 0
No embeds

No notes for slide

Rubinius - Improving the Rails ecosystem

  1. 1. Improving the Rails ecosystem The Rubinius Virtual Machine 1
  2. 2. Thanks EY! 2
  3. 3. Be thinking of questions
  4. 4. a_better_ruby == a_better_rails # => true
  5. 5. Brand new code base
  6. 6. Write in ruby first. Then C if you have to.
  7. 7. If you’re not failing every now and again, it’s a sign you’re not doing anything very innovative. Woody Allen
  8. 8. A work in progrees
  9. 9. Nov. 3: 1.0 preview End of 07: 1.0
  10. 10. You’re the customer
  11. 11. Help me help you.
  12. 12. Tell me your pain.
  13. 13. Some current pain
  14. 14. Memory usage Memory
  15. 15. • 1.8 garbage collector is simple, but too simple. • Rubinius uses modern techniques to decrease memory usage and increase throughput Memory 15
  16. 16. The forking problem Memory
  17. 17. In 1.8... • Start up a mongrel. • Require all your code. • fork() the process. • Watch your memory double. Memory 17
  18. 18. In Rubinius... • Start up a mongrel. • Require all your code. • fork() the process. • Watch NO change in the memory footprint! Memory 18
  19. 19. Memory change per additional mongrel instance 1 2 3 4 1.8 rubinius 19
  20. 20. Packaging / Deployment
  21. 21. .rba == .jar .rba == .war Packaging
  22. 22. • Precompiled code (.rbc) • Meta data about project • RDoc • Assets Packaging 22
  23. 23. Performance
  24. 24. Built for change Performance
  25. 25. Modern Techniques • Inline caching • Pre-compiled code • JIT (eventually) Performance 25
  26. 26. 3 legged dog turtles space shuttle rubinius Performance 26
  27. 27. Error reporting
  28. 28. Normal Backtraces An exception has occurred: User requested termination with Control-C (Interrupt) Backtrace: Readline.readline at kernel/core/readline.rb:52 main.__script__ at lib/bin/sirb.rb:78 main.load at kernel/core/compile.rb:78 main.require at kernel/core/compile.rb:129 Array#each at kernel/core/array.rb:526 Integer(Fixnum)#times at kernel/core/integer.rb:19 Array#each at kernel/core/array.rb:526 main.require at kernel/core/compile.rb:112 Array#each at kernel/core/array.rb:526 Integer(Fixnum)#times at kernel/core/integer.rb:19 Array#each at kernel/core/array.rb:526 main.require at kernel/core/compile.rb:111 main.__script__ at kernel/loader.rb:159 Reporting 28
  29. 29. C extensions can misbehave Reporting
  30. 30. VALUE test_segfault(VALUE self) { // Get a pointer to address 4. char *i = (char*)4; // Attempt to read from address 4 // which is definitely not allowed. x = *i; // Never get this far. return Qnil; } Raises an exception! Segfault detected in function 0x90a00 (accessing 0x4) (MemorySegmentionError) SomeExtension#test_segfault at extensions/test/test.c main.__script__ at extensions/test/test.rb:38 main.load at kernel/core/compile.rb:95 main.__script__ at kernel/loader.rb:122 Reporting
  31. 31. Time lost to segfaults (in minutes) 1.8 rubinius 200 200 150 100 70 50 30 10 6 2 1 3 5 31
  32. 32. Profiling
  33. 33. In 1.8... • Profiling is instrumented only. • The speed hit is prohibitive for running in production mode Profiling 33
  34. 34. In Rubinius... • Sampling profiler available always • Has little to no impact on performance Profiling 34
  35. 35. In my_app.rb require ‘simple_profile’ profile(:profile1) do obj.run_slow_method end shell# rbx profiler --analyze profile1.results Profiling 35
  36. 36. In environment.rb require ‘simple_profile’ SimpleProfiler.profile_actions SimpleProfiler.profile_views shell# rbx profiler --analyze actions.results shell# rbx profiler --analyze views.results Profiling 36
  37. 37. Disclaimer
  38. 38. • All statements and numbers and opinions are only those of Evan Phoenix. • All statistics are made up, but represent a general trend. 38
  39. 39. Evan Phoenix evan@fallingsnow.net ephoenix@engineyard.com 39

×