Slide 1

Slide 1 text

Cores Unleashed Exploiting Parallelism in Ruby with STM Szu-Kai Hsu @brucehsu

Slide 2

Slide 2 text

@brucehsu

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

There was a time...

Slide 5

Slide 5 text

There was a time... when programmers were happy (relatively)

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

“Global Interpreter Lock is a mechanism used in computer language interpreters to synchronize the execution of threads so that only one thread can execute at a time. An interpreter which uses GIL will always allow exactly one thread to execute at a time, even if run on a Multi-core processor. Some popular interpreters that have GIL are CPython and Ruby MRI.” http://en.wikipedia.org/wiki/ GlobalInterpreterLock

Slide 15

Slide 15 text

Alternative implementations Those using fine-grained locks » JRuby » Rubinius » MacRuby

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

Beautiful Concurrency, Simon Peyton Jones 2007 1.Taking too few locks 2.Taking too many locks 3.Taking the wrong locks 4.Taking locks in the wrong orders 5.Error recovery 6.Lost wake-ups and erroneous retries

Slide 20

Slide 20 text

Software Transactional Memory

Slide 21

Slide 21 text

Transaction Attributes - Atomicity - Consistency - Isolation - Durability

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

STM is a sound Abstraction of locks

Slide 24

Slide 24 text

How do we implement STM in Ruby?

Slide 25

Slide 25 text

Why not in Go?

Slide 26

Slide 26 text

Why not a new VM?

Slide 27

Slide 27 text

RunVM

Slide 28

Slide 28 text

Live Demo?

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

Why Go? And I say, why not? » Easier to write » Good performance » Growing community and resources » Goroutines and channels » Go is for Hipsters

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

RunVM Specification » Subset of tinyrb » Stack-based VM » Thanks to Ruby Under a Microscope

Slide 33

Slide 33 text

Transactional Locking II

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

Thanks!