The Wayback Machine - https://web.archive.org/web/20071118113618/http://glu.ttono.us:80/articles/2005/10/14/yarv-progress-report

YARV Progress Report

Posted by kev Sat, 15 Oct 2005 02:29:00 GMT

Koichi SASADA

Caution! (review)

  • I can’t speak English well
    • If I say strange English, you can see the slide page ** Or ask another Japanese. They can speak English well.
    • If you have any queestions, ask me with: ** Japanese (recommended) ** Ruby, C, Scheme, Java, … ** IRC (#rubyconf on freenode)

Agenda

  • Self Introduction and Japanese Activities
  • Overview of YARV
  • Goal of YARV
  • Current YARV status
    • YARV Design, Optimization Review
    • Evaluation
  • Conclusion

Self Introduction

  • “SASADA” the family name
  • “Koichi” is given name -> “ko1”
  • A Student for Ph.D. 2nd grade (Not a Son-shi)
    • Systems Software for Multithreaded Arch ** SMT/CMP or other tech ** i.e.: Hypter threeading (Intel), CMT (Sun), Power (IBM) ** OS, Library, Compiler and Interpreter ** YARV is my first step for parallel interpreter
    • Computer Architecture for Next Generation at Public Position
  • Nihon Ruby no Kai
    • Organized by Mr. Takahashi (maki)
  • “Rubyist Magazine”:http://jp.rubyist.net/magazine
    • vol 10 at 10 Oct 2005
    • 1st anniversary at 6 Sep 2005 (vol 9)
  • Ruby-dev summary
  • English Diary some days
    • But retired

Our Activity: Rubyist Magazine

  • Many Japanese articles related to Ruby
    • Cooperate with Ruby Code & Style?
    • I’m writing YARV internal named “YARV Maniacs”
  • Many interviews of Japanese Rubyists

RubyMa!

  • Published 1 Apr 2005 (April Fools)
    • Joke web-zine
  • Parody of Negima!
  • Many useful articles
    • The Takahashi method: def Takahashi end

Overview of YARV

Overview: Background

  • Ruby is used world-wide, (one of)? the most comfortable programming languages
  • Ruby is slow, because interpreter doesn’t use Virtual Machine Technology
  • We need Ruby VM!

  • “YARV: Yet Another Ruby VM”:http://www.atdot.net/yarv/

    • Started development on 1 Jan 2004 ** At that time, there were some VMS for Ruby
  • Ruby’s license, of course

Overview: FAQ (review of last year FAQ)

  • Q: How is “YARV” pronounced?
  • A: You can pronounce “YARV” what you like.
  • Q: Should I remember the name “YARV”?
  • A: No. If YARV succeeds, it gets renamed to Rite, if it doesn’t, no one will remember it
    • About YARV, name is NOT ???

Overview: YARV System

Ruby Program –> Compiler –> YARV Instruction Sequence –> ==> Virtual Machine ==> AOT Compiler –> C Source –>

Overview: Current Interpreter

  • Ruby Program: a = b + c
  • Syntax tree: (a =) -> (method dispatch + (b), (c))
  • Current interpreter traverses AST directly

Overview YARV - Stack Machine

The Goal of YARV

  • YARV: Yet Another RubyVM -> The RubyVM
    • To be the Ruby 2.0 VM Rite
  • Fastest Ruby Interpreter
    • Easy to be the current Ruby interpreter

The Goal of YARV (cont.)

  • Support all Ruby features
    • Include Ruby 2.0 new syntaxes
  • Native thread support
    • Concurrent execution (Giant VM lock)
    • Parallel execution on parallel machine
  • Multi-VM instance
    • Same as Mutlti-VM in Java

Goal: Ruby 2.0 syntax

  • Matz will decide it :-)
  • ”{|…| …}” == “->(…){ … }”
    • “I think this is ugly” – Ko1
  • Multiple-values
    • Same as Array? Or first class multiple-values support?
  • Selector-namespace?

Goal: Native Thread Support

  • Three different thread models
  • Model 1: User-level thread (green)
    • same as current Rubt interpreter
  • Model 2: Native thread with giant VM lock
    • Same as current Ruby interpreter
    • Easy to implement
  • Model 3: Native-thread with fine grain lock
    • Run ruby threads in parallel
    • For enterprise?

Goal: Native Thread Support (cont.)

h5. Current Ruby Interpreter & Model 1

  • CPU1: Thread 1 -> Thread 2 -> Thread 1
  • CPU2: Idle……..

h5. Model 2: Native thread with Giant VM Lock

  • CPU1: Thread 1 -> (Lock) -> (in OS thread 2) Thread 2 -> (Lock) -> Thread 1
  • CPU2: Idle……..

On this system, other threads can run (but the Ruby threads switch cpus with a lock)

h5. Model 3: Native thread with Fine Grain Lock

  • CPU1: Thread 1……
  • CPU2: Thread 2……

Goal: Native Thread Support Summary

|. |. Model 1|. Model 2|. Model 3| |Scalability|Bad|Bad?|Best |Lock overhead|No|Some|High| |Impl. Difficulty|Norm|Easy|Hard| |Portability|Good|Bad|Bad|

Goal: Multi-VM Instance

  • Current Ruby process: ( Process ( Ruby Interpreter (VM) ) )
  • Ruby Process with Multi-VM Instance ( Process ((many) Ruby Interpreter (VM) ) )

  • Current Ruby can hold only 1 interpreter in 1 process

    • Interpreter structure causes this problem
    • Using many global variables
  • Multiple-VM instance

    • Running some VM in 1 process
    • It will help ruby embedded apps ** mod_ruby, etc.

Multi-VM Instance + Thread Model 2

CPU1: Thread 1 -> (Lock of VM1) -> Thread 2 -> Lock of VM1

Goal: Load Map

  • All Ruby features support
    • Feb. 2006 … ?
  • Native Thread Support
    • Experimental: Dec. 2005
    • Complete: 2006?(model 2) 2007?(model 3)
  • Multi-VM support
    • Experimental Feb 2006
    • Complete: 2006?

Current Status of YARV

Status: System

Some almosts, an incomplete and a not yet

Status: Supported Ruby Features

  • Almost all Ruby features
  • Not supported:
    • Few syntaxes … {|*arg| …}
    • Visibility
    • Safe level ($SAFE)
    • Some methods written in C for current Ruby implementation
    • Around Signal
    • C extension libraries ** (Because YARV can’t run mkmf.rb)

Status: Versions

  • 0.2 YARV as C Extension
    • Need a patch to Ruby interpeter
  • 0.3 (2005-8): YARV as Ruby Interpreter
    • merged to Ruby source (1.9 HEAD)
    • Maintained on my subversion repository
  • Latest version: 0.2
    • Native thread (pthread / Win32) supports model 2

YARV 0.2.x

(Ruby Interpreter (Evaluator)) -> YARV (Compiler, VM, Optimizer) -> back

YARV 0.3.x

  • YARV marged with Ruby Interpreter

  • Future work

    • Generational GC
    • m17n

“Status: Compile & Disasm CGI”:http://www.atdot.net/yc/

Status: VM Design

  • 5 registers
    • PC: Program Counter
    • SP: Stack Pointer
    • CFP: Controler Frame Pointer
    • LFP: LOcal frame pointer
    • DFP: Dynamic Frame Pointer
  • Some stack frame
  • Control stack and value stack

Status: Optimization

  • Simple Stack Virtual Machine
    • Re-design Exception handling
  • Peep-hole optimization on compile time
    • I gave up static program analysis
    • Dynamicity is your friend but my ENEMY!
  • Direct Threaded code with GCC
  • Specialized Instruction
    • i.e. Ruby program “x+y” compiled to special instruction instead of a method dispatch instruction
  • In-line Cache
    • In-line Method Cache
    • In-line constant value cache ** Because ruby’s “constant variable” is not constant!
  • Embed values in an instruction sequence
  • Unified Instruction
    • Operands Unification
    • *InsnA x -> InsnA_x
  • Unified instructions are auto generated by VM gen
    • I only decide which instructions should be combined
  • Stack Caching
  • JIT Compilation
    • I made easy one for x86, but…
    • Too hard to do alone. I retired.
  • AOT Compilation
    • YARV bytecode -> C Source
    • Easy to develop
    • Hard to support exception

Status: Demo

  • YARV building demo?
  • YARV running demo?

Status: Evaluation

  • Yield block is not fast (2-3 times faster than C Ruby) - optimizing this will be work for the future
  • With all optimizations, basic math can see a 50 times performance gain over C Ruby
  • Ackermann can see 20 times gain over C Ruby
  • Wow - YARV as it stands stacks up really well against other interpreters for basic math type stuff

Status: Awards

  • 2004: Funded by IPA Exploratory Software Development “Youth”
    • IPA: Information-technology Promotion Agency, Japan
  • 2005: Funded by IPA Exploratory Software Development (continuance)
  • 2004: got awarded “Super creator” from IPA

Conclusion

  • YARV supports almost all Ruby syntax
  • YARV suppoorts some RUby libraries
  • YARV 0.3.2 supports native thread
  • YARV achieves significant speedup for ruby programs which have VM bottleneck
    • This means that we can enjoy Symbol programming with Ruby

Conclusion: Future Work

  • Support all Ruby features
    • mkmf.rb
  • Support every thread model
    • especially 2 and 3
  • Support multi-VM Instance

How Can You Help me

  • Any comments are welcome
    • Build reports, Bug reports, architecture reports, …
  • yarv-devel Mailing List
    • English ML for YARV development ** Matz and other Japanese join
  • “YARV Wiki”:http://yarv.rubyforge.org/pukiwki/pukiwiki.php
  • Give me a job! (I’ll finish my course 2 years later)

Special Thanks

  • Matz the architect of Ruby
  • IPA: His sponsor
  • YARV development ML subs
  • All rubyists

Q&A

  • All: We want the demo!

    • ko1: OK
  • Derek Sivers: A bunch of Japanese :-)

    • ko1: Some more Japanese

Posted in ,  | 1 comment | no trackbacks

Comments

  1. Avatar Pawel said about 3 hours later:

    Derek said something to the effect of ‘Your English was very good. Good job!’

    Sasada-san just replied to thank him.

Trackbacks

Use the following link to trackback from your own site:
http://glu.ttono.us/articles/trackback/16

Comments are disabled