rubinius - improving the rails ecosystem

39
Improving the Rails ecosystem The Rubinius Virtual Machine 1

Upload: evanphx

Post on 15-May-2015

6.453 views

Category:

Business


1 download

DESCRIPTION

A talk on Rubinius at RailsConf Europe 2007.

TRANSCRIPT

Page 1: Rubinius - Improving the Rails ecosystem

Improving the Rails ecosystem

The Rubinius Virtual Machine

1

Page 2: Rubinius - Improving the Rails ecosystem

Thanks EY!

2

Page 3: Rubinius - Improving the Rails ecosystem

Be thinking of questions

Page 4: Rubinius - Improving the Rails ecosystem

a_better_ruby==

a_better_rails

# => true

Page 5: Rubinius - Improving the Rails ecosystem

Brand new code base

Page 6: Rubinius - Improving the Rails ecosystem

Write in ruby first.Then C if you have to.

Page 7: Rubinius - Improving the Rails ecosystem

If you’re not failing every now and again, it’s a sign you’re not doing anything very innovative.

Woody Allen

Page 8: Rubinius - Improving the Rails ecosystem

A work in progrees

Page 9: Rubinius - Improving the Rails ecosystem

Nov. 3: 1.0 previewEnd of 07: 1.0

Page 10: Rubinius - Improving the Rails ecosystem

You’re the customer

Page 11: Rubinius - Improving the Rails ecosystem

Help me help you.

Page 12: Rubinius - Improving the Rails ecosystem

Tell me your pain.

Page 13: Rubinius - Improving the Rails ecosystem

Some current pain

Page 14: Rubinius - Improving the Rails ecosystem

Memory usage

Memory

Page 15: Rubinius - Improving the Rails ecosystem

• 1.8 garbage collector is simple, but too simple.

• Rubinius uses modern techniques to decrease memory usage and increase throughput

15

Memory

Page 16: Rubinius - Improving the Rails ecosystem

The forking problem

Memory

Page 17: Rubinius - Improving the Rails ecosystem

• Start up a mongrel.

• Require all your code.

• fork() the process.

• Watch your memory double.

17

In 1.8...

Memory

Page 18: Rubinius - Improving the Rails ecosystem

• Start up a mongrel.

• Require all your code.

• fork() the process.

• Watch NO change in the memory footprint!

18

In Rubinius...

Memory

Page 19: Rubinius - Improving the Rails ecosystem

19

1 2 3 4

1.8 rubinius

Memory change peradditional mongrel instance

Page 20: Rubinius - Improving the Rails ecosystem

Packaging / Deployment

Page 21: Rubinius - Improving the Rails ecosystem

.rba == .jar.rba == .war

Packaging

Page 22: Rubinius - Improving the Rails ecosystem

• Precompiled code (.rbc)

• Meta data about project

• RDoc

• Assets

22

Packaging

Page 23: Rubinius - Improving the Rails ecosystem

Performance

Page 24: Rubinius - Improving the Rails ecosystem

Built for change

Performance

Page 25: Rubinius - Improving the Rails ecosystem

Modern Techniques

• Inline caching

• Pre-compiled code

• JIT (eventually)

25

Performance

Page 26: Rubinius - Improving the Rails ecosystem

26

3 legged dog turtles space shuttle rubinius

Performance

Page 27: Rubinius - Improving the Rails ecosystem

Error reporting

Page 28: Rubinius - Improving the Rails ecosystem

28

Normal Backtraces

An exception has occurred: User requested termination with Control-C (Interrupt)

Backtrace: Readline.readline at kernel/core/readline.rb:52 main.__script__ at lib/bin/sirb.rb:78 main.load at kernel/core/compile.rb:78 main.require at kernel/core/compile.rb:129 Array#each at kernel/core/array.rb:526 Integer(Fixnum)#times at kernel/core/integer.rb:19 Array#each at kernel/core/array.rb:526 main.require at kernel/core/compile.rb:112 Array#each at kernel/core/array.rb:526 Integer(Fixnum)#times at kernel/core/integer.rb:19 Array#each at kernel/core/array.rb:526 main.require at kernel/core/compile.rb:111 main.__script__ at kernel/loader.rb:159

Reporting

Page 29: Rubinius - Improving the Rails ecosystem

C extensions can misbehave

Reporting

Page 30: Rubinius - Improving the Rails ecosystem

Reporting

Segfault detected in function 0x90a00 (accessing 0x4) (MemorySegmentionError)

SomeExtension#test_segfault at extensions/test/test.c main.__script__ at extensions/test/test.rb:38 main.load at kernel/core/compile.rb:95 main.__script__ at kernel/loader.rb:122

VALUE test_segfault(VALUE self) { // Get a pointer to address 4. char *i = (char*)4; // Attempt to read from address 4 // which is definitely not allowed. x = *i; // Never get this far. return Qnil;}

Raises an exception!

Page 31: Rubinius - Improving the Rails ecosystem

31

Time lost to segfaults

50

100

150

200

1 3 5

2 6 10

30

70

200

1.8 rubinius

(in minutes)

Page 32: Rubinius - Improving the Rails ecosystem

Profiling

Page 33: Rubinius - Improving the Rails ecosystem

In 1.8...

• Profiling is instrumented only.

• The speed hit is prohibitive for running in production mode

33

Profiling

Page 34: Rubinius - Improving the Rails ecosystem

In Rubinius...

• Sampling profiler available always

• Has little to no impact on performance

34

Profiling

Page 35: Rubinius - Improving the Rails ecosystem

35

require ‘simple_profile’

profile(:profile1) do obj.run_slow_methodend

shell# rbx profiler --analyze profile1.results

Profiling

In my_app.rb

Page 36: Rubinius - Improving the Rails ecosystem

36

require ‘simple_profile’

SimpleProfiler.profile_actionsSimpleProfiler.profile_views

shell# rbx profiler --analyze actions.resultsshell# rbx profiler --analyze views.results

In environment.rb

Profiling

Page 37: Rubinius - Improving the Rails ecosystem

Disclaimer

Page 38: Rubinius - Improving the Rails ecosystem

• All statements and numbers and opinions are only those of Evan Phoenix.

• All statistics are made up, but represent a general trend.

38