Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
The future of Ruby is faster
Search
Dirkjan Bussink
June 29, 2013
Technology
3
530
The future of Ruby is faster
Talk given at Euruko 2013
Dirkjan Bussink
June 29, 2013
Tweet
Share
More Decks by Dirkjan Bussink
See All by Dirkjan Bussink
Managing a widely distributed team
dbussink
1
170
Time
dbussink
0
93
The tricky truth about parallel execution and modern hardware
dbussink
0
330
Security for dummies
dbussink
1
140
The myth of dynamic language performance
dbussink
3
420
Rubinius - Tales from the trenches @ Railsclub.ru 2012
dbussink
2
200
Rubinius - Tales from the trenches @ Baruco 2012
dbussink
1
250
Rubinius Eurucamp 2012 Workshop
dbussink
2
110
Rubinius Euruko 2012 Lightning talk
dbussink
2
230
Other Decks in Technology
See All in Technology
dev 補講: プロダクトセキュリティ / Product security overview
wa6sn
1
2.3k
SREによる隣接領域への越境とその先の信頼性
shonansurvivors
2
510
Incident Response Practices: Waroom's Features and Future Challenges
rrreeeyyy
0
160
Why does continuous profiling matter to developers? #appdevelopercon
salaboy
0
180
AWS Media Services 最新サービスアップデート 2024
eijikominami
0
190
Terraform未経験の御様に対してどの ように導⼊を進めていったか
tkikuchi
2
430
[FOSS4G 2019 Niigata] AIによる効率的危険斜面抽出システムの開発について
nssv
0
310
Terraform CI/CD パイプラインにおける AWS CodeCommit の代替手段
hiyanger
1
240
信頼性に挑む中で拡張できる・得られる1人のスキルセットとは?
ken5scal
2
520
マルチプロダクトな開発組織で 「開発生産性」に向き合うために試みたこと / Improving Multi-Product Dev Productivity
sugamasao
1
300
地理情報データをデータベースに格納しよう~ GPUを活用した爆速データベース PG-Stromの紹介 ~
sakaik
1
150
Platform Engineering for Software Developers and Architects
syntasso
1
510
Featured
See All Featured
Designing the Hi-DPI Web
ddemaree
280
34k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
28
2k
A better future with KSS
kneath
238
17k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.8k
What's new in Ruby 2.0
geeforr
343
31k
Documentation Writing (for coders)
carmenintech
65
4.4k
Ruby is Unlike a Banana
tanoku
97
11k
The Cult of Friendly URLs
andyhume
78
6k
Automating Front-end Workflow
addyosmani
1366
200k
The Cost Of JavaScript in 2023
addyosmani
45
6.7k
A Modern Web Designer's Workflow
chriscoyier
693
190k
How To Stay Up To Date on Web Technology
chriscoyier
788
250k
Transcript
The future of Ruby is faster Euruko 2013 Saturday, June
29, 13
Dirkjan Bussink @dbussink Saturday, June 29, 13
Rubinius Use Ruby Saturday, June 29, 13
Saturday, June 29, 13
Saturday, June 29, 13
“Everything you heard about Ruby being slow is not true.
It’s about twice as slow as that” Saturday, June 29, 13
Saturday, June 29, 13
The lure of the hash table Saturday, June 29, 13
class MethodTable def initialize @methods = {} end def store_method(name,
code) @methods[name] = code end def find_method(name) @methods[name] end end Saturday, June 29, 13
class Address def initialize @instance_variables[:street] = "Pantheon" @instance_variables[:number] = 1
@instance_variables[:city] = "Athens" end end Saturday, June 29, 13
Hash tables everywhere! Saturday, June 29, 13
Inline caching Saturday, June 29, 13
p = Person.new p.name Saturday, June 29, 13
p = Person.new p.name <receiver_class_id, code> Saturday, June 29, 13
“There are 2 hard problems in computer science: caching, naming,
and off-by-1 errors” Saturday, June 29, 13
Global serial number Saturday, June 29, 13
http://jamesgolick.com/2013/4/14/mris-method-caches.html https://charlie.bz/blog/things-that-clear-rubys-method-cache Saturday, June 29, 13
Per class serial number Saturday, June 29, 13
Probably in 2.1 Saturday, June 29, 13
Instance variable packing Saturday, June 29, 13
class Address def initialize @street = "Pantheon" @number = 1
@city = "Athens" end end Address.instance_variable_get("@seen_ivars") => [:@street, :@number, :@city] Saturday, June 29, 13
0001: push_ivar :@number self[1] Removes hash table lookup Saturday, June
29, 13
Just in time compilation Saturday, June 29, 13
def method1 1 + method2 end def method2 2 +
1 end 100000.times do method1 end Saturday, June 29, 13
def method1 1 + method2 end def method2 2 +
1 end 100000.times do method1 end ... 0x110ed90e7 mov $0x9, %eax 0x110ed90ec jmp 0x119 ; 0x110ed9129 ... 0x110ed9129 addq $0xa0, %rsp 0x110ed9130 pop %rbp 0x110ed9131 ret Saturday, June 29, 13
def method1 1 + method2 end def method2 2 +
1 end 100000.times do method1 end ... 0x110ed90e7 mov $0x9, %eax 0x110ed90ec jmp 0x119 ; 0x110ed9129 ... 0x110ed9129 addq $0xa0, %rsp 0x110ed9130 pop %rbp 0x110ed9131 ret b0100 (4) b1000 (8) b1001 (9) Saturday, June 29, 13
def method1 1 + method2 end def method2 2 +
1 end 100000.times do method1 end ... 0x110ed90e7 mov $0x9, %eax 0x110ed90ec jmp 0x119 ; 0x110ed9129 ... 0x110ed9129 addq $0xa0, %rsp 0x110ed9130 pop %rbp 0x110ed9131 ret b0100 (4) b1000 (8) b1001 (9) Saturday, June 29, 13
Saturday, June 29, 13
Creating less garbage Saturday, June 29, 13
a = Address.new a.street = "Pantheon" a.number = "1" a.city
= "Athens" Rubinius.memory_size(a) => 56 VS Rubinius.memory_size(a) => 160 Saturday, June 29, 13
Saturday, June 29, 13
2.1 Saturday, June 29, 13
Auto tuning Saturday, June 29, 13
Parallelism Saturday, June 29, 13
Higher throughput Saturday, June 29, 13
Concurrency Saturday, June 29, 13
Shorter stop the world Saturday, June 29, 13
thread 1 thread 2 thread 3 Saturday, June 29, 13
thread 1 thread 2 thread 3 GC thread Saturday, June
29, 13
thread 1 thread 2 thread 3 GC thread Long GC
pauses be gone! Saturday, June 29, 13
http://rubini.us/2013/06/22/concurrent-garbage-collection/ Saturday, June 29, 13
How much does it help? Saturday, June 29, 13
Before Saturday, June 29, 13
Lifting the server siege... done. Transactions: 501 hits Response time:
0.02 secs Transaction rate: 51.70 trans/sec Throughput: 1.46 MB/sec Concurrency: 1.00 Longest transaction: 0.15 Shortest transaction: 0.01 Saturday, June 29, 13
Lifting the server siege... done. Transactions: 501 hits Response time:
0.02 secs Transaction rate: 51.70 trans/sec Throughput: 1.46 MB/sec Concurrency: 1.00 Longest transaction: 0.15 Shortest transaction: 0.01 Sad long wait time :( Saturday, June 29, 13
Lifting the server siege... done. Transactions: 1032 hits Response time:
0.04 secs Transaction rate: 102.79 trans/sec Throughput: 2.91 MB/sec Concurrency: 4.00 Longest transaction: 0.28 Shortest transaction: 0.02 Saturday, June 29, 13
Lifting the server siege... done. Transactions: 1032 hits Response time:
0.04 secs Transaction rate: 102.79 trans/sec Throughput: 2.91 MB/sec Concurrency: 4.00 Longest transaction: 0.28 Shortest transaction: 0.02 Not so good concurrency Saturday, June 29, 13
After Saturday, June 29, 13
Lifting the server siege... done. Transactions: 599 hits Response time:
0.02 secs Transaction rate: 61.06 trans/sec Throughput: 1.73 MB/sec Concurrency: 1.00 Longest transaction: 0.03 Shortest transaction: 0.01 Saturday, June 29, 13
Lifting the server siege... done. Transactions: 599 hits Response time:
0.02 secs Transaction rate: 61.06 trans/sec Throughput: 1.73 MB/sec Concurrency: 1.00 Longest transaction: 0.03 Shortest transaction: 0.01 No more long pause! Saturday, June 29, 13
Lifting the server siege... done. Transactions: 1374 hits Response time:
0.02 secs Transaction rate: 176.38 trans/sec Throughput: 5.00 MB/sec Concurrency: 3.99 Longest transaction: 0.04 Shortest transaction: 0.01 Saturday, June 29, 13
Lifting the server siege... done. Transactions: 1374 hits Response time:
0.02 secs Transaction rate: 176.38 trans/sec Throughput: 5.00 MB/sec Concurrency: 3.99 Longest transaction: 0.04 Shortest transaction: 0.01 More req/s! Saturday, June 29, 13
1 client: 51 => 61 req/s 4 clients: 102 =>
176 req/s Saturday, June 29, 13
Concurrency & parallelism Saturday, June 29, 13
No GIL/GVL! Saturday, June 29, 13
Future is multi-core Saturday, June 29, 13
We need new API’s Saturday, June 29, 13
Parallel each Saturday, June 29, 13
Thread safe collections Saturday, June 29, 13
What about you as a developer? Saturday, June 29, 13
Be nice Saturday, June 29, 13
Write type stable code Saturday, June 29, 13
Small and simple methods Saturday, June 29, 13
Benchmark! Saturday, June 29, 13
? Saturday, June 29, 13