rubinius - improving the rails ecosystem
DESCRIPTION
A talk on Rubinius at RailsConf Europe 2007.TRANSCRIPT
![Page 1: Rubinius - Improving the Rails ecosystem](https://reader033.vdocument.in/reader033/viewer/2022052619/5555a8dcd8b42a52568b47dc/html5/thumbnails/1.jpg)
Improving the Rails ecosystem
The Rubinius Virtual Machine
1
![Page 2: Rubinius - Improving the Rails ecosystem](https://reader033.vdocument.in/reader033/viewer/2022052619/5555a8dcd8b42a52568b47dc/html5/thumbnails/2.jpg)
Thanks EY!
2
![Page 3: Rubinius - Improving the Rails ecosystem](https://reader033.vdocument.in/reader033/viewer/2022052619/5555a8dcd8b42a52568b47dc/html5/thumbnails/3.jpg)
Be thinking of questions
![Page 4: Rubinius - Improving the Rails ecosystem](https://reader033.vdocument.in/reader033/viewer/2022052619/5555a8dcd8b42a52568b47dc/html5/thumbnails/4.jpg)
a_better_ruby==
a_better_rails
# => true
![Page 5: Rubinius - Improving the Rails ecosystem](https://reader033.vdocument.in/reader033/viewer/2022052619/5555a8dcd8b42a52568b47dc/html5/thumbnails/5.jpg)
Brand new code base
![Page 6: Rubinius - Improving the Rails ecosystem](https://reader033.vdocument.in/reader033/viewer/2022052619/5555a8dcd8b42a52568b47dc/html5/thumbnails/6.jpg)
Write in ruby first.Then C if you have to.
![Page 7: Rubinius - Improving the Rails ecosystem](https://reader033.vdocument.in/reader033/viewer/2022052619/5555a8dcd8b42a52568b47dc/html5/thumbnails/7.jpg)
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](https://reader033.vdocument.in/reader033/viewer/2022052619/5555a8dcd8b42a52568b47dc/html5/thumbnails/8.jpg)
A work in progrees
![Page 9: Rubinius - Improving the Rails ecosystem](https://reader033.vdocument.in/reader033/viewer/2022052619/5555a8dcd8b42a52568b47dc/html5/thumbnails/9.jpg)
Nov. 3: 1.0 previewEnd of 07: 1.0
![Page 10: Rubinius - Improving the Rails ecosystem](https://reader033.vdocument.in/reader033/viewer/2022052619/5555a8dcd8b42a52568b47dc/html5/thumbnails/10.jpg)
You’re the customer
![Page 11: Rubinius - Improving the Rails ecosystem](https://reader033.vdocument.in/reader033/viewer/2022052619/5555a8dcd8b42a52568b47dc/html5/thumbnails/11.jpg)
Help me help you.
![Page 12: Rubinius - Improving the Rails ecosystem](https://reader033.vdocument.in/reader033/viewer/2022052619/5555a8dcd8b42a52568b47dc/html5/thumbnails/12.jpg)
Tell me your pain.
![Page 13: Rubinius - Improving the Rails ecosystem](https://reader033.vdocument.in/reader033/viewer/2022052619/5555a8dcd8b42a52568b47dc/html5/thumbnails/13.jpg)
Some current pain
![Page 14: Rubinius - Improving the Rails ecosystem](https://reader033.vdocument.in/reader033/viewer/2022052619/5555a8dcd8b42a52568b47dc/html5/thumbnails/14.jpg)
Memory usage
Memory
![Page 15: Rubinius - Improving the Rails ecosystem](https://reader033.vdocument.in/reader033/viewer/2022052619/5555a8dcd8b42a52568b47dc/html5/thumbnails/15.jpg)
• 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](https://reader033.vdocument.in/reader033/viewer/2022052619/5555a8dcd8b42a52568b47dc/html5/thumbnails/16.jpg)
The forking problem
Memory
![Page 17: Rubinius - Improving the Rails ecosystem](https://reader033.vdocument.in/reader033/viewer/2022052619/5555a8dcd8b42a52568b47dc/html5/thumbnails/17.jpg)
• 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](https://reader033.vdocument.in/reader033/viewer/2022052619/5555a8dcd8b42a52568b47dc/html5/thumbnails/18.jpg)
• 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](https://reader033.vdocument.in/reader033/viewer/2022052619/5555a8dcd8b42a52568b47dc/html5/thumbnails/19.jpg)
19
1 2 3 4
1.8 rubinius
Memory change peradditional mongrel instance
![Page 20: Rubinius - Improving the Rails ecosystem](https://reader033.vdocument.in/reader033/viewer/2022052619/5555a8dcd8b42a52568b47dc/html5/thumbnails/20.jpg)
Packaging / Deployment
![Page 21: Rubinius - Improving the Rails ecosystem](https://reader033.vdocument.in/reader033/viewer/2022052619/5555a8dcd8b42a52568b47dc/html5/thumbnails/21.jpg)
.rba == .jar.rba == .war
Packaging
![Page 22: Rubinius - Improving the Rails ecosystem](https://reader033.vdocument.in/reader033/viewer/2022052619/5555a8dcd8b42a52568b47dc/html5/thumbnails/22.jpg)
• Precompiled code (.rbc)
• Meta data about project
• RDoc
• Assets
22
Packaging
![Page 23: Rubinius - Improving the Rails ecosystem](https://reader033.vdocument.in/reader033/viewer/2022052619/5555a8dcd8b42a52568b47dc/html5/thumbnails/23.jpg)
Performance
![Page 24: Rubinius - Improving the Rails ecosystem](https://reader033.vdocument.in/reader033/viewer/2022052619/5555a8dcd8b42a52568b47dc/html5/thumbnails/24.jpg)
Built for change
Performance
![Page 25: Rubinius - Improving the Rails ecosystem](https://reader033.vdocument.in/reader033/viewer/2022052619/5555a8dcd8b42a52568b47dc/html5/thumbnails/25.jpg)
Modern Techniques
• Inline caching
• Pre-compiled code
• JIT (eventually)
25
Performance
![Page 26: Rubinius - Improving the Rails ecosystem](https://reader033.vdocument.in/reader033/viewer/2022052619/5555a8dcd8b42a52568b47dc/html5/thumbnails/26.jpg)
26
3 legged dog turtles space shuttle rubinius
Performance
![Page 27: Rubinius - Improving the Rails ecosystem](https://reader033.vdocument.in/reader033/viewer/2022052619/5555a8dcd8b42a52568b47dc/html5/thumbnails/27.jpg)
Error reporting
![Page 28: Rubinius - Improving the Rails ecosystem](https://reader033.vdocument.in/reader033/viewer/2022052619/5555a8dcd8b42a52568b47dc/html5/thumbnails/28.jpg)
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](https://reader033.vdocument.in/reader033/viewer/2022052619/5555a8dcd8b42a52568b47dc/html5/thumbnails/29.jpg)
C extensions can misbehave
Reporting
![Page 30: Rubinius - Improving the Rails ecosystem](https://reader033.vdocument.in/reader033/viewer/2022052619/5555a8dcd8b42a52568b47dc/html5/thumbnails/30.jpg)
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](https://reader033.vdocument.in/reader033/viewer/2022052619/5555a8dcd8b42a52568b47dc/html5/thumbnails/31.jpg)
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](https://reader033.vdocument.in/reader033/viewer/2022052619/5555a8dcd8b42a52568b47dc/html5/thumbnails/32.jpg)
Profiling
![Page 33: Rubinius - Improving the Rails ecosystem](https://reader033.vdocument.in/reader033/viewer/2022052619/5555a8dcd8b42a52568b47dc/html5/thumbnails/33.jpg)
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](https://reader033.vdocument.in/reader033/viewer/2022052619/5555a8dcd8b42a52568b47dc/html5/thumbnails/34.jpg)
In Rubinius...
• Sampling profiler available always
• Has little to no impact on performance
34
Profiling
![Page 35: Rubinius - Improving the Rails ecosystem](https://reader033.vdocument.in/reader033/viewer/2022052619/5555a8dcd8b42a52568b47dc/html5/thumbnails/35.jpg)
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](https://reader033.vdocument.in/reader033/viewer/2022052619/5555a8dcd8b42a52568b47dc/html5/thumbnails/36.jpg)
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](https://reader033.vdocument.in/reader033/viewer/2022052619/5555a8dcd8b42a52568b47dc/html5/thumbnails/37.jpg)
Disclaimer
![Page 38: Rubinius - Improving the Rails ecosystem](https://reader033.vdocument.in/reader033/viewer/2022052619/5555a8dcd8b42a52568b47dc/html5/thumbnails/38.jpg)
• All statements and numbers and opinions are only those of Evan Phoenix.
• All statistics are made up, but represent a general trend.
38