Rubinius - A Tool of the Future

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    7 Favorites

    Rubinius - A Tool of the Future - Presentation Transcript

    1. A Tool of the Future aka the road to enlightenment 1
    2. Ask/give questions/comments. Both nice and nasty.
    3. Mantra of rubinius If it can be done in ruby, then it shouldn’t be in C. 3
    4. An idealist is a person who helps other people to be prosperous. Henry Ford
    5. the edges of the sword are life and death no one knows which is which Ikkyū Sōjun
    6. If you’re not failing every now and again, it’s a sign you’re not anything very innovative. Woody Allen
    7. KHAAAAANN! James T. Kirk
    8. • What is (and is not) rubinius? • Who is rubinius? • Features and Goals • Timeline • Technical Details • Demo / Questions 9
    9. http://rubini.us
    10. What. • A brand new ruby engine • Bytecode Virtual Machine based • Generational Garbage Collection 11
    11. Why. • Fun • A desire for a better interpreter 12
    12. Why pt. 2 • Every talk at this conference has mentioned some limitation of ruby. • All limitations are limitations of the current interpreter, not the language. 13
    13. What it’s not. • Vaporware • A thesis project • Finished. 14
    14. Who. • Aki Reijonen (loop) Evan Phoenix (evan) • Mat Elder (mae) Brian Ford (brixen) • John Hornbeck (hornbeck) Wilson Bilkovich (Defiler) • Carsten Bormann (cabo) Pat Eyler (pate) • Devin Walters (defn) Alan Hurdle (hurdlea) • Frederick Ros (sleeper) Thomas Lockney (tlockney) • Alexander Kellet (lypanov) Eero Saynatkai (rue) • Mikko Lehtonen (scoopr) 15
    15. Features and Goals • Remember the Mantra! • VM in C only • Includes primitive operations • Extensive tests and specs • Core library in ruby • Array#dup, Method#new, Object#instance_eval 16
    16. • 1.8.5 compatible • 98% first class • Easy to understand, easy to extend, easy to optimize • MRI (Matz Ruby Interpreter) C API compatible 17
    17. Timeline. • 1.0 by October, 2007 - RubyConf • Near 100% compatible with 1.8.5 • Able to run rails 1.2 • 2.0 • JIT • Optimizers 18
    18. Technical Details • 5 core sections • CPU • Primitives • Compiler • Object Memory / Garbage Collection • Core library 19
    19. CPU • Fully bytecode based • All bytecodes are written test first • Leverage GCC to make help make fast 20
    20. Threads • Currently supports green threads • Contains low level sychronization / sharing mechanism called Channel • A PI Calculus-like channel • Native Thread support in a MxN scheme • (eventually) 21
    21. Primitives • The most basic method • Written C (for now) • Provide most basic functionality 22
    22. Compiler • Completely written in ruby • COMPLETELY WRITTEN IN RUBY • Self bootstrapped from initial rubinius prototype • Pipeline based architecture 23
    23. # rbx sirb -p -s -b sirb(eval):000> puts “hello evan”
    24. puts "hello evan"
    25. [:newline, 1, "(eval)", [:fcall, :puts, [:array, [:str, "hello evan"]]]]
    26. #line 1 push_literal 0 string_dup push self send puts 1 ret
    27. "v00000000:fC0000 0000)000000010000 0001'0000"
    28. • Every stage is directly accessible • Think: new parsers that output rubinius assembly • LISP • Smalltalk • Erlang 29
    29. • Compiler is a normal class, which open doors... • Compile ERB templates directly into CompiledMethods • Ability to remove Kernel#eval if an application of rubinius warrants it 30
    30. “The Reaper” (Object Memory / Garbage Collection) • Generational Collector • Young Objects: Baker two-space compacting collector • Mature Objects: Mark/Sweep collector 31
    31. Infanticide • Young objects live fast and die young (usually) • Once an object survives for a while, it’s promoted to the mature object space. • Compaction keeps the memory footprint small. 32
    32. The Old Guard • Mature objects are collected 10 to 30 times less often than young objects. • All object access in VM is done through the “write barrier”, which maintains the set of mature objects that reference young objects. • Objects themselves are not marked, making rubinius very “fork friendly”. 33
    33. Core library • Everything you’ve come to love, now in written in ruby. 34
    34. def [](arg, len = nil) if len len = len.to_i return nil if len < 0 end if arg.is_a? String unless len.nil? raise ArgumentError.new("String#[] cannot accept a second argument with a String.") end return (self.include?(arg) ? arg.dup : nil) elsif arg.respond_to? :match m = arg.match(self) return m[len.to_i] if m && len return m[0] if m return nil elsif arg.respond_to?(:first) and arg.respond_to?(:last) from = arg.first to = arg.last to -= 1 if arg.respond_to?(:exclude_end?) && arg.exclude_end? size = self.size from = from + size if from < 0 to += size if to < 0 len = to - from + 1 self[from, len] elsif arg and arg.respond_to?(:to_i) arg = arg.to_i String#[] size = self.size arg = arg + size if arg < 0 if 0 <= arg && arg < size if len len = size - arg if arg + len >= size substring(arg, len) else @data[arg] end else # invalid start index len ? "" : nil end else raise ArgumentError.new("String#[] cannot accept #{arg.class} objects") end
    35. def parent a=3 ask_child(a) puts "OMG #{a} PONIES!" end def ask_child(initial_pony_count) ctx = MethodContext.current.sender # Will be ctx.locals[:a] = 9 soon. ctx.locals[2] = 9 end parent()
    36. OMG 9 PONIES!
    37. Nothing is sacred. (evil built in)
    38. Backtraces vatu :: rbx-branches/event> ./shotgun/rubinius ctx.rb An exception has occured: No method 'ask_child' on an instance of Object. (NoMethodError) Backtrace: NoMethodError#initialize at core/exception.rb:47 NoMethodError.new at bootstrap/class.rb:8 main.ask_child (method_missing) at bootstrap/method_missing.rb:8 main.parent at ctx.rb:3 main.__script__ at ctx.rb:12 main.load at core/compile.rb:56 main.__script__ at core/__loader.rb:95 39
    39. MethodTables class Blah end class Foo def hello puts “hello evan” end end Blah.methods[:hello_also] = Foo.methods[:hello] Blah.new.hello_also # hello evan 40
    40. It’s your party. class Mu < nil end p Mu.instance_methods # [] p Mu.superclass # nil you still mad? 41
    41. Zen and the Art of Object Creation 42
    42. VM level Sampler s = Sampler.new(100) # 100 hz s.start 100000.times { 1 + 1 } s.stop s.results.size # 332 43
    43. CompiledMethods m = Array.methods[:index] p m # #<CompiledMethod:0x32a34 ...> p m.name # :index 44
    44. But what does that all mean?!
    45. We all know and love introspection, so take that to the next level...
    46. • Better debbugers • Read MethodContext objects directly • Richer information • Read method cache’s to find out common classes for arguments and locals 47
    47. A Better Tool.
    48. !=
    49. How you can help • Write tests / specs • Write core library functionality • Write VM code • Port valgrind to OS X • Bounty available! 50
    50. Evan Phoenix http://rubini.us 51

    + evanphxevanphx, 3 years ago

    custom

    10032 views, 7 favs, 4 embeds more stats

    An introduction to the ruby interpreter rubinius, a more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 10032
      • 9799 on SlideShare
      • 233 from embeds
    • Comments 0
    • Favorites 7
    • Downloads 1
    Most viewed embeds
    • 187 views on http://maulanaruby.wordpress.com
    • 30 views on http://thegeekintheshell.blogspot.com
    • 15 views on http://doesnotunderstand.free.fr
    • 1 views on http://74.125.91.132

    more

    All embeds
    • 187 views on http://maulanaruby.wordpress.com
    • 30 views on http://thegeekintheshell.blogspot.com
    • 15 views on http://doesnotunderstand.free.fr
    • 1 views on http://74.125.91.132

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories

    Tags