rubinius for you - goruco

Post on 31-Aug-2014

867 Views

Category:

Technology

3 Downloads

Preview:

Click to see full reader

DESCRIPTION

Evan Phoenix' presentation at GoRuCo

TRANSCRIPT

Rubinius For You

Evan Phoenix Jun 4th, 2011

★ @evanphx ♘ github.com/evanphx

The Year Rubinius Breaks Through

2011

Why Bother?

We can have it better

Why Bother?

Not a single release, a philosophy

Why Bother?

Improve over time

Why Bother?

Improve

Performance

Why Bother?

Improve

Tooling

Why Bother?

Improve

Developer Experience

Why Bother?

What’s Next?

2.0

What’s Next?

2.0

Ruby 1.9 support

What’s Next?

2.0

Concurrency

What’s Next?

2.0

Microsoft Windows support

What’s Next?

Real World

When programs stop being polite and start getting real.

Real World

Rubinius slower than it should be

Real World

Profiling is key to improving

Real World

Profiling is key to improving

Example

Real World

WARNING:SCIENCE AHEAD

A method seems slow

Problem:

Step 1

Improving

Step 1

Benchmark

Improving

require 'benchmark'cc = CoworkersCode.new

Benchmark.bm do |x| x.report("initial") { cc.calculate_awesome_score }end

user system total realinitial 0.071788 0.001601 0.073389 ( 29.998823)

user system total realinitial 0.071788 0.001601 0.073389 ( 29.998823)

29.998823

user: 0.071788system: 0.001601 total: 0.073389 real: 29.998823

Time running code

User

Time inside the kernel

System

Sum of user and system

Total

Elapsed wall clock

Real

Topic

Wall Clock

user: 0.071788system: 0.001601 total: 0.073389 real: 29.998823

0.073389

29.998823!=??

Step 2

Profile

Improving

» rbx -Xprofile scratch/profile_sample.rb

% cumulative self self total time seconds seconds calls ms/call ms/call name------------------------------------------------------------ 99.69 30.00 30.00 10 3000.10 3000.10 Rubinius::Channel#receive_timeout 0.13 0.04 0.04 2 19.82 19.82 IO.open_with_mode 0.11 0.03 0.03 1 33.05 33.05 IO::Buffer#fill 0.02 0.01 0.01 18 0.30 0.30 FFI::Platform::POSIX.stat

» rbx -Xprofile -Xprofiler.graph scratch/profile_sample.rb

0.00 30.00 10/60 Kernel#sleep [15][16] 99.9 30.00 0.00 10 Rubinius::Channel#receive_timeout [16]

0.00 30.00 10/20 CoworkersCode#superhero_factor [14][15] 99.9 0.00 30.00 10 Kernel#sleep [15] 30.00 0.00 10/10 Rubinius::Channel#receive_timeout [16]

def superhero_factor sleep 3 rand(10) end

Step 3

Fix and benchmark

Improving

user system total realinitial 0.000102 0.000047 0.000149 ( 0.000139)

0.000139

0.073389

29.998823!=

Invisible in all but real

Sleep!

A method seems slow

Problem:

SOLVED!

Rubinius can tune your code itself

Real World

Rubinius can tune your code itself

Dynamic is not dynamic all the time

Real World

“It’s ducks all the way down.”

- Sandi Metz

Rubinius can tune your code itself

Most of yours quack the same though!

Real World

def last_part(str) str.split(“ “).lastend

def last_part(str) str.split(“ “).lastend

21%

1 class98%

1: 25245 2: 275 3: 86 4: 50 5: 35 6: 6 7: 10 8: 5 9: 5 10: 2 10+: 34

Call sites running Array specs

Rubinius can tune your code itself

Shoot first, let the VM sort it out.

Real World

Made for ruby applications

Real World

Made for ruby applications

Ruby is objects

Real World

Made for ruby applications

Rubinius is made for objects

Real World

Made for ruby applications

Lots of objects

Real World

“To optimize, I make sure not to create objects.”

- Ryan Smith

1. 10,000,000 timesa. Create 101 objectsb. Save one of them

https://gist.github.com/1008305

0

500

1000

1500

2000

2500

3000

MBs

mri

1. 10,000,000 timesa. Create 101 objectsb. Save one of them

Saved objects: 10,000,000

0

500

1000

1500

2000

2500

3000

MBs

mri rbx

0

50

100

150

200

250

300

MBs

mri rbx

0

12

23

35

47

58

70

100k 200k 300k 400k

MBs

mri rbx

0

750

1,500

2,250

3,000

mri rbx

57

531

Memory Time

Made for ruby applications

Love thy objects

Real World

Next Steps

More profiling, more tuning

Next Steps

Newer, smarter compiler

Next Steps

Rubinius and You

Compatibly is there

Rubinius and You

Rubinius isn’t terrible for any workload

Rubinius and You

Rubinius is amazing for some

Rubinius and You

Try Rubinius!

Rubinius and You

Stickers in the back!

Rubinius and You

Shirts email us!

Rubinius and You

community@rubini.us

Use it in production=>

blog post about you

Rubinius Reward

Thanks!

Evan Phoenix Jun 4th, 2011

★ @evanphx ♘ github.com/evanphx

Technology

Efficient Memory Layout

Rubinius

obj.ivars = { :@name => “Evan”, :@age => 31}

obj.class.ivars = { :@name => 0, :@age => 1}

obj.ivars = [ “Evan”, 31]

Flags

Class

Extra Ivars

@name

@age

top related