Speedup
Ruby Interpreter
Koichi Sasada<ko1@heroku.com>

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Today’s talk
• Ruby 2.1 and Ruby 2.2• How to speed up Ruby interpreter?
• Evaluator• Threading• Object management / Garbage collection

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Koichi Sasada as a Japanese• Koichi Sasada a.k.a. ko1• From Japan• 笹田 (family name) 耕一 (givenname) in Kanji character• “Ichi” means “1” or first• This naming rule represents I’m
the first son of my parents• Ko”ichi” → ko1

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Koichi Sasada as a Programmer• CRuby/MRI committer• Virtual machine (YARV) from Ruby 1.9• YARV development since 2004/1/1• Recently, improving GC performance• Matz team at Heroku, Inc.
• Full-time CRuby developer• Working in Japan• Director of Ruby Association
Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

The Ruby Association was founded to further
development of the programming language Ruby.
The goals of the Ruby Association are to improve
relationship between Ruby-related projects,
communities and businesses, and to address issues
connected with using Ruby in an enterpriseenvironment.
Quoted from http://www.ruby.or.jp/en/

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Advertisement• Foundation to encourage Ruby dev. andcommunities• Activities• Ruby programmer certification program• http://www.ruby.or.jp/en/certification/examination/ in English• Grant project. We have selected 3 proposals in 2013
• Ruby Prize• To recognize the efforts of “New members” to the Ruby
community• http://www.ruby.or.jp/en/news/20140627.html• Maintenance of Ruby (Cruby) interpreter• Now, it is for Ruby 2.0.0• Events, especially RubyWorld Conference• http://www.rubyworld-conf.org/• Donation for Ruby
developments and communities
Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Advertisement

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Advertisement
http://www.ruby.or.jp/en/news/20140627.html

http://www.ruby.or.jp/en/news/20131018e.html

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Advertisement
http://www.rubyworld-conf.org/

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Advertisement

Heroku, Inc. http://www.heroku.com
You should know about Heroku!!

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Advertisement

Check https://www.heroku.com/features
Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

• Heroku, Inc. http://www.heroku.com• Heroku supports OSSs / Ruby development• Many talents for Ruby, and also other languages• Heroku employs 3 Ruby interpreter coredevelopers• Matz• Nobu• Ko1 (me)• We name our group “Matz team”
Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

“Matz team”

Nobu @ Tochigi
Patch monster

Matz @ Shimane
Title collector

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

ko1 @ Tokyo
EDD developer

Matz
Title collector• He has so many (job) title• Chairman - Ruby Association• Fellow - NaCl
• Chief architect, Ruby - Heroku• Research institute fellow – Rakuten• Chairman – NPO mruby Forum• Senior researcher – Kadokawa Ascii Research Lab• Visiting professor – Shimane University• Honorable citizen (living) – Matsue city
• Honorable member – Nihon Ruby no Kai• …

• This margin is too narrow to contain
Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Nobu
Patch monster• Great patch creator

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Nobu isGreat Patch Monster
COMMITRATIOIN LAST 5 YEARS
davidflanagan
technorama
a_matsuda
iwamatsu
murakenheadiusgotoken
okkez
eban
evan
kanemoto
tmm1
seki
arton
hsbt
jeg2
luislavena
takano32
duerst
kouji
suke
keiju
azav
wanabengoto
eregonnagai
xibbarshirosaki
charliesome
ryan
sorah
tarui
ayumin
nahi
ktsj
glass
nari
shyouheiemboss
mrkn
0%
0%
0%
0%
0%
0%
0%
0%
0%
0%
0%
0%
kou
0%
0%
0%
0%
yugui
0%
0%
nagachika
0%
1%
1%
shugo
1%
1%
knu
1%
nobu
1%
tadf
1%
29%
mame
2%
marcandre
2%
matz
2%
tenderlove
2%
zzak
2%
kazu
2%
2%
kosaki3%drbrain

3%

ko1
4%usa
naruse
4% 8%

svn
9%

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

akr
12%

Ko1
EDD developer
EurukoCommit number of ko1 (last 3 years)
2013
RubyKaigi
2013
RubyConf
RubyConf
2012
2013

25

20

15

Ruby 2.0
105

EDD: Event Driven Development
Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

2013/11/8

2013/9/8

2013/7/8

2013/5/8

2013/3/8

2013/1/8

2012/11/8

2012/9/8

2012/7/8

2012/5/8

2012/3/8

2012/1/8

2011/11/8

2011/9/8

2011/7/8

2011/5/8

2011/3/8

2011/1/8

2010/11/8

0“Mission of Matz team”

Improve quality ofnext version of CRuby
Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

“Mission of Matz team”• Improve quality of next version of CRuby• Matz decides a spec finally• Nobu fixed huge number of bugs
• Ko1 improves the performance• Next version of CRuby is “Ruby 2.2.0”

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

http://www.flickr.com/photos/loginesta/5266114104

Ruby 2.1
Current stable
Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Ruby 2.1
a bit old Ruby
• Ruby 2.1.0 was released at 2013/12/25• New features• Performance improvements• Ruby 2.1.1 was released at 2014/02/24• Includes many bug fixes found after 2.1.0 release• Introduce a new GC tuning parameter to change
generational GC behavior (introduce it later)• Ruby 2.1.2 was released at 2014/05/09• Solves critical bugs (OpenSSL and so on)

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Ruby 2.1 the biggest change
Version policy• Change the versioning policy• Drop “patch level” in the version• Major version: Big language changes (or anniversary)• Minor version: minor language changes (or annually)• Teeny version: fixing bugs with compatibility• Release new teeny versions about every 3 month• Teeny upgrades keep compatibility

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Ruby 2.1 New syntax• New syntaxes• Required keyword
parameter• Rational number literal• Complex number literal• `def’ returns symbol ofmethod namehttp://www.flickr.com/photos/rooreynolds/4133549889

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Ruby 2.1 Syntax
Required keyword parameterdef foo(a:1, b:)…
endfoo(a: 1, b: 2)foo()foo(a: 1)

# OK
# NG
# NG

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Ruby 2.1 Syntax
Required keyword parameter• Keyword argument (from Ruby 2.0.0)• def foo(a: 1, b: 2); end• `a’ and `b’ are optional parameters• OK: foo(); foo(a: 1); foo(a: 1, b: 2); foo(b: 2)• Required keyword argument from 2.1• def foo(a: 1, b: )• `a’ is optional, but `b’ is required parameter• OK: foo(a: 1, b: 2); foo(b: 2)• NG: foo(); foo(a: 1)

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Ruby 2.1 Syntax
Rational number literals
1/2r #=> Rational(1, 2)

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Ruby 2.1 Syntax
Rational number literals• To represent ½, in Ruby “Rational(1, 2)”→ Too long!!
• Introduce “r” suffix½ → 1/2r• “[digits]r” represents “Rational([digits], 1)”• ½ → 1/2r
• 1/2r#=> 1/Rational(2, 1)• 1/Rational(2, 1) #=> Rational(1/2)

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Ruby 2.1 Syntax
Complex number literals
1+2i #=> Complex(1, 2)

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Ruby 2.1 Syntax
Complex number literals• We already have “Integer#i” method to makeimaginary number like “1+2.i”• We already introduced “r” suffix for Rational→ No reason to prohibit “i” suffix!!
• [digits]i represents “Complex(0, [digits])”• 1+2i #=> 1+Complex(0, 2)• 1+Complex(0, 2) #=> Complex(1, 2)• You can mix “r” and “i” suffix
Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Ruby 2.1 Syntax
Return value of `def’ syntax

def foo()…
end#=> :foo
Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Ruby 2.1 Syntax
Return value of `def’ syntax• Return value of method definition• Method definition syntax returns symbol ofdefined method name• `def foo; …; end’ #=> :foo

• Method modifier methods• Example:• private def foo; …; end• public static void def main(args); …; end

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Ruby 2.1 Runtime new features• String#scrub• Process.clock_gettime• Binding#local_variable_get/set• Bignum now uses GMP (if available)• Extending ObjectSpace

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Performance improvements• Optimize “string literal”.freeze• Sophisticated inline method cache• Introducing Generational GC: RGenGC

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

RGenGC: Generational GC for Ruby
• RGenGC: Restricted Generational GC• Generational GC (minor/major GC uses M&S)
• Dramatically speedup for GC-bottleneck applications• New generational GC algorithm allows mixing “Writebarrier protected objects” and “WB unprotected objects”→ No (mostly) compatibility issue with C-exts• Inserting WBs gradually• We can concentrate WB insertion efforts for major objects
and major methods• Now, most of objects (such as Array, Hash, String, etc.) are
WB protected• Array, Hash, Object, String objects are very popular in Ruby
• Array objects using RARRAY_PTR() change to WB unprotected
objects (called as Shady objects), so existing codes still works.
Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Accumulated execution time (sec)

RGenGC
Performance evaluation (RDoc)
14
12
10
8
6

About x15 speedup!

4
20
Total mark time (ms)w/o RGenGC

Total sweep time (sec)
RGenGC* Disabled lazy sweep to measure correctly.

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

http://www.flickr.com/photos/adafruit/8483990604

Ruby 2.2
Next version
Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Schedule of Ruby 2.2• Not published officially• Schedule draft is available by Naruse-san• https://bugs.ruby-lang.org/projects/rubytrunk/wiki/ReleaseEngineering22

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Ruby 2.2 schedule
2013/12Ruby 2.1.0

Deccan
RubyConf
7/19

2014/12/25

We arehere!

Ruby 2.2.0

RubyConf
Brasil8/28, 29
RubyKaigi
9/18, 19, 20

RubyConf
11/17, 18, 19

Events are important for
EDD (Event Driven Development) Developers
Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Ruby 2.2 (rough) schedule
2013/12Ruby 2.1.0

2014/12/25
Ruby 2.2.0

Sep/2014
Preview 1

We arehere!

Big feature freeze

26th,Jul/2014
Dev. Meeting

Bug fix only

Feature proposal

Nov/2014
Preview2
Feature freeze

Aug/2014
Dev. Meeting
Feature proposal

Critical Bug fix only

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Dec/2014
Releasecandidate2.2 big features (planned)• New syntax: not available now• New method: no notable methods availablenow• Libraries:• Minitest and test/unit will be removed (provided bybundled gem)

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

2.2 internal changes• Internal• C APIs• Hide internal structures for Hash, Struct and so on• Remove obsolete APIs

• GC
• Symbol GC (merged recently)• 2age promotion strategy for RGenGC• Incremental GC to reduce major GC pause time

• VM
• More sophisticated method cache
Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Ruby 2.2 internals
Symbol GC
1_000_000.times{|i| i.to_s.to_sym}
p Symbol.all_symbols.size# Ruby 2.1#=> 1,002,376# Ruby 2.2 (dev)#=> 25,412
Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Ruby 2.2 internals
Symbol GC• Symbols remain forever → Security issue• “n.times{|i| i.to_s.to_sym}”
creates “n” symbols and they are never collected• Symbol GC: Collect dynamically created symbols

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

http://www.flickr.com/photos/donkeyhotey/8422065722

Break

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Speedup
Ruby Interpreter
How do we speed up Ruby interpreter?

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Software consists ofmany components
Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Ruby’s components
Ruby
scriptBundledLibraries

Gem
Libraries

Embeddedclasses and methods(Array, String, …)

Parse

CompileThreading

Evaluator

Ruby
BytecodeInterpret on RubyVM
Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Objectmanagement(GC)Working for core components• Core components I’m working for:• Evaluator (10 years)• Thread management (10 years)• Memory management (few years)

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

History of Ruby interpreter
1993 2/24
Birth of Ruby
(in Matz’ computer)

1996/12Ruby 1.0

1995/12Ruby 0.95

1999/12Ruby 1.4

1998/12Ruby 1.2

2000/6
Ruby 1.6

2003/8Ruby 1.8
2009/1
Ruby 1.9.0

2013/2
Ruby 2.0

2013/12Ruby 2.1.0

1st release2004/1YARV development
2013/3RGenGC
Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Introduce our effort(especially my contributions)to speedup Ruby interpreter

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Evaluator
Ruby
scriptBundledLibraries

Gem
Libraries

Embeddedclasses and methods(Array, String, …)

Parse

CompileThreading

Evaluator

Ruby
BytecodeInterpret on RubyVM
Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Objectmanagement(GC)Evaluator• Named YARV: Yet another RubyVM• Start until 10 years ago (2004/01/01)• Simple stack machine architecture• Execute each bytecode instructions one by one• Apply many known optimization techniques

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Evaluator
Compile Ruby to AST
Abstract Syntax Tree

Ruby Program
Parse

a=b+c

a=
MethodDispatch(:+)

b
Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014c

Evaluator
Compile AST to Bytecode
Abstract Syntax TreeVM Instructionsa=getlocalgetlocalsend
setlocalMethodDispatch(:+)

bcTree databc+aSequential data

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Evaluator
Execution as stack machine
Ruby Program

a=b+cCompileYARV Instructions

getlocalgetlocalsend
setlocal

b
c
+
a

a
b+c
b

c

c

b+c
b
VM Stack

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Evaluator
Optimizations• Apply many techniques to improve performance• Peephole optimizations• Specialized instructions• Stack frame layout• Efficient exception handling• Efficient block representation• Direct threading• Stack caching• Instructions and operands unifications•…
Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Evaluator
Optimizations• Analysis usage
And optimize for frequent cases• Example: Exception handling• Exceptions occur *EXCEPTIONAL* so
optimize for no-exception control flow

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Performance evaluationcompare with Ruby 1.8
Higher is good

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Main components• Evaluator• Thread management• Memory management

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Threading
Ruby
scriptBundledLibraries

Gem
Libraries

Embeddedclasses and methods(Array, String, …)

Parse

CompileThreading

Evaluator

Ruby
BytecodeInterpret on RubyVM
Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Objectmanagement(GC)Threading• Using native threads for each Ruby threads• Parallel ruby execution is prohibited by GVL• You can free GVL if you write a code carefully in C level
and run it in parallel

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Threading
Ruby 1.8 and before

CPU 1

Thread 1

Thread 2

Thread 1
OS Thread 1

CPU 2

IDLE

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Threading
Layered view
Ruby
RT

Native Thread
System S/W

RT

NT

・・・

RT

・・・

Thread Scheduler

S/W
H/W

Processor(s)PEPE

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

・・・

PE

Threading
Ruby 1.9 and later
Native threads with Giant VM Lock
Thread 1

Thread 1
CPU 1

OS Thread 1

Lock
Thread 2

Lock
OS Thread 2

CPU 2

IDLE
Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Threading
Layered view
Ruby

Native Thread
System S/W

RT

RT

NT

NT

・・・

・・・

RT

NT

Thread Scheduler

S/W
H/W

Processor(s)PEPE

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

・・・

PE

Threading
Why GVL?
• To protect Ruby users from nightmare
debugging• Shared parallel threading can make nondeterministic bugs which is too hard to debug• Disadvantage• CRITICAL ISSUE: No parallel programming in
Ruby• Need another programming model for parallel• Current *SHARED EVERYTHING* model is not match• Correct isolation level for each parallel execution
units
Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Object management (GC)
Ruby
scriptBundledLibraries

Gem
Libraries

Embeddedclasses and methods(Array, String, …)

Parse

CompileThreading

Evaluator

Ruby
BytecodeInterpret on RubyVM
Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Objectmanagement(GC)Object and memory management• “Object.new” allocate a new object• “foo” (string literal) also allocate a new object• Everything are objects in Ruby!

• We don’t need to “de-allocate” objects manually

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Garbage collection
The automatic memory management

http://www.flickr.com/photos/circasassy/6817999189/

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Automatic memory management
Basic concept• Garbage collector recycled “unused” objects
automatically

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Mark & Sweep algorithm
Root objects
traverse
freemarkedtraverse

traverse

markedtraverse

markedmarkedtraversefree

1. Mark reachable
objects from rootobjects
2. Sweep unmarked
objects (collection
and de-allocation)

Collect unreachable
objects

markedfree
Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Generational GC (GenGC)• Weak generational hypothesis:“Most objects die young”

http://www.flickr.com/photos/ell-r-brown/5026593710→ Concentrate reclamation effort
only on the young objects
Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Generational hypothesis
Object lifetime in RDoc
(How many GCs surviving?)

Percentage of dead object#

100
90

95% of objects dead by the first GC

80

70
60
50
40
30
20
10
0
0

3

6

9 12 15 18 21 24 27 30 33 36 39 42 45 48 51 54 57 60 63 66 69 72 75 78 81 84 87 90 93 96 99 102

Lifetime (Survibing GC count)
Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Generational GC (GenGC)• Separate young generation and old generation• Create objects as young generation• Promote to old generation after surviving n-th GC• In CRuby, n == 1 (after 1 GC, objects become old)
• n == 2 from Ruby 2.2 (plan)• Usually, GC on young space (minor GC)• GC on both spaces if no memory (major/full GC)

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

GenGC [Minor M&S GC] (1/2)
1st MinorGC• Mark reachable objects fromroot objects.

Root objects
traverse

new/
free

new
old
traverse

traversenew/freecollectnewoldtraverse
new
old

new
old
traverse
newold• Mark and promote to oldgeneration• Stop traversing after old
objects→ Reduce mark overhead• Sweep not (marked or old)
objects• Can’t collect Some
unreachable objects
Don’t collect old object
•
old/
free

evenSpeedup
if it isRuby
unreachable.
interpreter, Koichi Sasada,
DeccanRubyConf2014

GenGC [Minor M&S GC] (2/2)
2nd MinorGC• Mark reachable objects fromroot objects.

Root objects
traverse

new/
free

old
ignoreignorenew/freecollectoldignoreold

oldignoreold• Mark and promote to oldgeneration• Stop traversing after old
objects→ Reduce mark overhead• Sweep not (marked or old)
objects• Can’t collect Some
unreachable objects
Don’t collect old object
•
old/
free

evenSpeedup
if it isRuby
unreachable.
interpreter, Koichi Sasada,
DeccanRubyConf2014

GenGC [Major M&S GC]• Normal M&S• Mark reachable objects fromroot objects

Root objects
traverse

new/
free

new
traverse

traverse

new/
free

• Mark and promote to old gen• Sweep unmarked objects

collectoldtraverse

oldnew• Sweep all unreachable(unused) objects

traverse
old

old/
free
collect
Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Accumulated execution time (sec)

RGenGC
Performance evaluation (RDoc)
14
12
10
8
6

About x15 speedup!

4
20
Total mark time (ms)w/o RGenGC

Total sweep time (sec)
RGenGC* Disabled lazy sweep to measure correctly.

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

RGenGC
Performance evaluation (RDoc)
Total execution time (sec)

140
120

16.04393815
4.946003494

100
80
60
40

103.7627479

102.3799865

w/o RGenGC

RGenGC20

0other than GC

GC* 12% improvements compare with w/ and w/o RGenGC
Ruby interpreter, Koichi Sasada,* DisabledSpeedup
lazy sweep
to measure correctly.
DeccanRubyConf2014

Speedup
Ruby Interpreter
How to speed up Ruby interpreter?

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

DO EVERYTHING!
NO SILVER BULLET!
Ruby
scriptBundledLibraries

Gem
Libraries

Embeddedclasses and methods(Array, String, …)

Parse

CompileThreading

Evaluator

Ruby
BytecodeInterpret on RubyVM
Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Objectmanagement(GC)DO EVERYTHING!
NO SILVER BULLET!
We did.
We are doing.
We will do!!

Only continuous effort
improves software quality.
Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Future work: Many many many!!
• Evaluator• JIT compilation• More drastic optimizations• Threading• Parallel execution model (not a thread?)• Object management and GC• Incremental GC• Compaction GC• Lightweight object allocation
Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Summary• Ruby 2.1 and Ruby 2.2• How to speed up Ruby interpreter?

• Evaluator• Threading• Object management / Garbage collection

One answers is:#=> Continue software development
Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014

Thank you for your attention
Q&A?
With slowly/clearly English, thank you.

Koichi Sasada<ko1@heroku.com>

Speedup Ruby interpreter, Koichi Sasada,
DeccanRubyConf2014