~/talk

Down the rb_newobj() Rabbit Hole: Garbage Collection in Ruby

Talkat RubyConf AU 2013 · 2013-02-20..02-22· [ruby]
links:none on file
slides:none on file

Shows that New Relic’s move to Ruby 1.9.3 cuts Ruby GC wall time (roughly 80 ms to 42 ms in one example) by changes under the hood, not by higher‑level patterns. Walks C code from rb_newobj() through class allocators, macros such as the RSTRING_PTR macro, embedded short‑string storage, heaps and free lists, and explains why classic mark‑and‑sweep and Ruby 1.9’s lazy sweep cost time. Demonstrates bitmap marking to enable shared memory / copy‑on‑write and why that reduces pauses.

AI-written summary · about

  1. 0:00Start
  2. 5:56What is GC? Garbage collector's function is to find data object that are no longer in use and make their space available for reuse by the running program
  3. 6:20ObjectSpace A module for interacting with garbage collection and traversing all living objects.
  4. 7:39Create a Class
  5. 8:35Empty the Array
  6. 9:03Remove the Class
  7. 10:29VALUE and Objects VALUE, an unsigned long, is a pointer to Ruby's objects.
  8. 12:20RBasic and RObject struct Basic
  9. 13:39RObject Structure
  10. 14:17Ruby and Macros Understanding C macros is essential to understanding Ruby source.
  11. 14:51RString Magic struct Basic basic
  12. 16:17RString Macros
  13. 18:41Ruby Heaps
  14. 21:50Define Alloc Method
  15. 23:32Create Ruby Object VALUE
  16. 24:59Get the Next Free Slot
  17. 25:32Return the Object
  18. 28:10Create Objects
  19. 28:21Object Allocation Heap
  20. 29:15Object Anatomy
  21. 30:32Sweep Phase Traverse every object in the object space. Those with a mark are unmarked. Those that are already unmarked are added to the free set.
  22. 32:50Copy-on-Write When a process is forked, memory is shared. Memory is copied only when it is changed. Marking an object is considered changing it.
  23. 33:56COW Anatomy Shared Heap Heap B
  24. 34:33Bitmap Marking Ruby 2.0 introduces a new type of garbage collection. FL_MARK flag has been moved to a bitmap memory structure.
  25. 35:01New Heap Anatomy
  26. 35:45Learn More Uniprocessor GC Techniques, Paul Wilson
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.