Rubinius - Improving the Rails ecosystem

  • View
    6.458

  • Download
    1

  • Category

    Business

Preview:

DESCRIPTION

A talk on Rubinius at RailsConf Europe 2007.

Citation preview

Improving the Rails ecosystem

The Rubinius Virtual Machine

1

Thanks EY!

2

Be thinking of questions

a_better_ruby==

a_better_rails

# => true

Brand new code base

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

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

Woody Allen

A work in progrees

Nov. 3: 1.0 previewEnd of 07: 1.0

You’re the customer

Help me help you.

Tell me your pain.

Some current pain

Memory usage

Memory

• 1.8 garbage collector is simple, but too simple.

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

15

Memory

The forking problem

Memory

• Start up a mongrel.

• Require all your code.

• fork() the process.

• Watch your memory double.

17

In 1.8...

Memory

• Start up a mongrel.

• Require all your code.

• fork() the process.

• Watch NO change in the memory footprint!

18

In Rubinius...

Memory

19

1 2 3 4

1.8 rubinius

Memory change peradditional mongrel instance

Packaging / Deployment

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

Packaging

• Precompiled code (.rbc)

• Meta data about project

• RDoc

• Assets

22

Packaging

Performance

Built for change

Performance

Modern Techniques

• Inline caching

• Pre-compiled code

• JIT (eventually)

25

Performance

26

3 legged dog turtles space shuttle rubinius

Performance

Error reporting

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

C extensions can misbehave

Reporting

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!

31

Time lost to segfaults

50

100

150

200

1 3 5

2 6 10

30

70

200

1.8 rubinius

(in minutes)

Profiling

In 1.8...

• Profiling is instrumented only.

• The speed hit is prohibitive for running in production mode

33

Profiling

In Rubinius...

• Sampling profiler available always

• Has little to no impact on performance

34

Profiling

35

require ‘simple_profile’

profile(:profile1) do obj.run_slow_methodend

shell# rbx profiler --analyze profile1.results

Profiling

In my_app.rb

36

require ‘simple_profile’

SimpleProfiler.profile_actionsSimpleProfiler.profile_views

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

In environment.rb

Profiling

Disclaimer

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

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

38

39

Evan Phoenixevan@fallingsnow.net

ephoenix@engineyard.com

Recommended