Toward
Lightning RubyVM
RubyKaigi2010
Technical Lightning Talk
Koichi Sasada
ko1@rvm.jp
Passionate VM Programmer
Creative Informatics,
Graduate School of Informaton Science and Technology,

The University of Tokyo

1

THIS PRESENTATION is about

Peformanceof RubyVM
Speed-up, Efficient,
Optimization, …
2

Our current Challenges
in Sasada-Lab (Students task)
 AOT Compiler Ruby to C
 Ruby to X10

 Profilers

 Memory Profiler Performance Profiler

Sessions atTomorrowMorning Regexp AOT Compiler Atomic-Ruby (for Embedded)
 CI (w/ performance) enviroment
3My Challenge VM re-design Re-visit Method (control) frame Re-visit Relationship of Ruby and C
 Instruction level re-design

 Introducing Parallelism
 Against Fine grain parallelism

 Against Coarse grain parallelism
4Easy Performance Analysis (1)Micro benchmark
Fib

Pentomino

OthersOthers
NotRuby

NotRuby

OthersOthers
Cfunc

Cfunc
MMGC
CompileOthers
Block

Insn

Obj
Insn

Method

VM

MM

Obj

VM

GC
CompileInst
Block

OS: Linux 2.6.31 32-bit
CPU: IntelCore2Quad 2.66GHz
Mem: 4GB
C Compiler: GCC 4.4.1, -O3
Profiled by OprofileMethodruby 1.9.3dev (2010-05-26)
Profiled by Mr. Shiba5

VM Re-design
Re-visit Method (control) frame
Current control frame structure
Args
LocalsStack
ValuesValue StackLFP SP
CFP
DFPBP, PC,… Control Frame Stack

Args
LocalsStack
Values

Method Invocation

Args
LocalsValue StackLFP SP
DFP
BP

LFP
DFP
BP, SP

CFP
Control Frame Stack

6

VM Re-design
Re-visit Method (control) frame
Current control frame structure• Too complicated
Args
Stack
Stack
Args
…
• Too
many values
to pushLocalsValuesValues Locals

Value StackLFP SPLFP structure→ Simplify
frame…
DFP
DFP
Block Invocation
Redesign:
BPBP, SP・VM framestructure
Args Stack Args
StackArgs…
ValuesLocalsValues Locals
・MethodLocals
datastructure
Value Stack・InstructionSequence structure
LFP SP
DFP
BP

…

LFP
DFP
BP, SPLFP SP
DFP
BP

7

Easy Performance Analysis (2)Macro Benchmark
rdoc
OthersRails
Others

Insn

Insn

MethodBlock
OthersCompileGC

VM

NotRuby

VM

MethodObj
Block
OthersCompileOthers

Cfunc

ObjGC

NotRuby

OthersCfunc

MM
OS: Linux 2.6.31 32-bit
CPU: IntelCore2Quad 2.66GHzMem: 4GBC Compiler: GCC 4.4.1, -O3
Profiled by OprofileMMruby 1.9.3dev (2010-05-26)
Profiled by Mr. Shiba
8

Introduce Parallelism
for Multi/Many core era Parallel, not concurrent
 Parallel: run simultaneously• Not supported by Ruby Concurrent: manage several activity• Supported by Ruby’s Thread9Introducing Parallelism
Principle

NO Parallel Threads
in CRuby
I believe parallel threads
introduce unhappy result.
10Introducing Parallelism
Fine grain parallelism
 Run methods in parallel Time consuming methods
 Collection of independentmethods

 Rubyist should not consider→ VM run them in parallel auto.
11Introducing Parallelism
Fine grain parallelism: Solution
 Write parallel code in C level C extension writer should takedifficulties

 Provide a framework to write

parallel C extensions
 Now considering specification
12

Introducing Parallelism
Coarse grain parallelism: Solution

 Easy to consider
 Separate logic into VMs using MVM(Multiple-VM)

 MVM, a.k.a vaporware (やるやる詐欺) VMs run in parallel and lightweight inter-VM communication than inter-process
communication

 Similar model as other languages
 Scala, Erlang, …

13

Introducing Parallelism
Parallel GC
 GC consume time

→ Speedup with Parallel Parallel mark
 I’m not sure about it, however, last

day nari-san talk it is considerable

 Parallel sweep
 Seems easy to support
14

Request
If you have applications(1) have performance issues(2) too slow, give up to run on Ruby

Please ask us.

They will be importantreseach materials.

我々の業界ではご褒美です．
15

Ono more
Announcement
 Escape from Japan (to UK) Next 2 months
 I hope I can concentrate in VM

development To: UK people, please contact me if
you have interest about my work
 Stay tuned for next news of VM

performance improvement

16

Summary

We have many Challenges

TowardLightning RubyVM
17

Thank youToward Lightning
RubyVM
RubyKaigi2010 Lightning Talk
Presented byKoichi Sasada
ko1@rvm.jp
18This presentation is
1st time about
 English presentation inRubyKaigi
 LT presentation in RubyKaigi
 No joking presentation
 Preparing script

19