Ruby’s bin men
Elise Huard - Euruko 05/2012
Friday, 1 June 12
Slide 2
Slide 2 text
Garbage collection?
Friday, 1 June 12
Slide 3
Slide 3 text
Automatic
Dynamic
Memory Management
Friday, 1 June 12
Slide 4
Slide 4 text
space leaks + dangling
pointers
abstraction
Friday, 1 June 12
Slide 5
Slide 5 text
Garbage Collection
Allocation
Friday, 1 June 12
Slide 6
Slide 6 text
Overhead: trade-offs
Friday, 1 June 12
Slide 7
Slide 7 text
Ruby: all in the heap
Friday, 1 June 12
Slide 8
Slide 8 text
Rails?
Friday, 1 June 12
Slide 9
Slide 9 text
I am the smallest rails app!
Here is my source code:
%w(action_controller/railtie coderay).map &method(:require)
run TheSmallestRailsApp ||= Class.new(Rails::Application) {
config.secret_token = routes.append { root to: 'hello#world' }.inspect
initialize!
}
class HelloController < ActionController::Base
def world
render inline: "
The Smallest Rails App
I am the smallest rails app!
Here is my source code:
#{CodeRay.scan_file(__FILE__, :ruby).div(line_numbers: :table)}
Make me smaller
"
end
end
Make me smaller
https://github.com/artemave/thesmallestrailsapp.com
The smallest Rails app
Friday, 1 June 12
Conservative
Mark-and-sweep
stop-the-world
Friday, 1 June 12
Slide 13
Slide 13 text
Mark
Flags
Next
...
RValue
FL_MARK
http://www.slideshare.net/authorNari/parallel-worlds-of-crubys-gc
Friday, 1 June 12
Slide 14
Slide 14 text
Sweep
http://patshaughnessy.net/2012/3/23/why-you-should-be-excited-about-garbage-collection-in-ruby-2-0
Flags
Next
...
RValue
next
in list
Friday, 1 June 12
Slide 15
Slide 15 text
Stop the world
Friday, 1 June 12
Slide 16
Slide 16 text
Ruby 1.9
Friday, 1 June 12
Slide 17
Slide 17 text
obj = Object.new
Lazy sweep
Friday, 1 June 12
Slide 18
Slide 18 text
RUBY_GC_MALLOC_LIMIT
RUBY_HEAP_MIN_SLOTS
RUBY_FREE_MIN
Tune with environment
Friday, 1 June 12
Slide 19
Slide 19 text
Tune with environment
Friday, 1 June 12
Slide 20
Slide 20 text
Aside: REE
Friday, 1 June 12
Slide 21
Slide 21 text
Ruby 2.0
Friday, 1 June 12
Slide 22
Slide 22 text
! copy on write friendly
Bitmap marking
Friday, 1 June 12
Slide 23
Slide 23 text
Parallel marking
Friday, 1 June 12
Slide 24
Slide 24 text
Rubinius
Friday, 1 June 12
Slide 25
Slide 25 text
• Nursery
• Young generation
• Mature generation
• (Large objects)
Generational GC
Friday, 1 June 12
Slide 26
Slide 26 text
Aside: kiji
Friday, 1 June 12
Slide 27
Slide 27 text
JRuby
Friday, 1 June 12
Slide 28
Slide 28 text
• Generational:
• Young (eden - Survivor1 -
Survivor2)
• Tenured
• Permanent Area
• minor/major garbage collection
JVM
Friday, 1 June 12
Slide 29
Slide 29 text
MacRuby &
RubyMotion
Friday, 1 June 12
Slide 30
Slide 30 text
Tools
Friday, 1 June 12
Slide 31
Slide 31 text
#define GC_PROFILE_MORE_DETAIL 1
...
#define GC_NOTICE 1
22 GC during init with default ruby 1.9.3-rc1
Friday, 1 June 12
Slide 32
Slide 32 text
Perftools.rb
Dtrace
Friday, 1 June 12
Slide 33
Slide 33 text
Friday, 1 June 12
Slide 34
Slide 34 text
• READ TEH CODES
• read this:
• read recent publications
on garbage collection
To know more
Friday, 1 June 12
Slide 35
Slide 35 text
Thank you
Friday, 1 June 12
Slide 36
Slide 36 text
Thank you
euruko2012 @elise_huard
Friday, 1 June 12