~/talk

Optimizing Ruby's Memory Layout

Talkat RubyConf 2021 · 2021-11-08..11-10· [ruby, web-performance]
slides:none on file

Proposal moves malloced object payloads into the ruby heap by allocating variable-size slots (power-of-two multiples of the 40‑byte rvalue) and per‑size size pools, placing payload immediately after the rvalue to improve cache locality. Implementation covers classes and strings, handles resizing by falling back to malloc today, and leans on compaction as a future fix. Microbenchmarks show 35% faster string compare and other ops faster; production testing across ~500M requests yields 4% memory reduction with no latency impact on 71‑byte strings.

AI-written summary · about

  1. 0:00Intro
  2. 0:48RVALUE structure
  3. 1:14Ruby Object Structure
  4. 1:40Heap page structure
  5. 2:43Allocating Ruby objects
  6. 3:45Ruby's garbage collector
  7. 4:16Marking phase
  8. 4:35Marking example
  9. 5:44Sweeping example
  10. 6:20Compact phase
  11. 6:50Compaction algorithm
  12. 7:08Compaction example
  13. 9:05Allocating an embedded string
  14. 10:57CPU cache properties
  15. 11:54Ruby cache performance
  16. 12:31Overhead of malloc
  17. 13:12The Variable Width Allocation project
  18. 13:48Variable Width cache performance
  19. 15:21RClass Allocation
  20. 17:33Size pools
  21. 18:55Types of String allocation
  22. 19:23Allocating a short string
  23. 20:13Allocating a longer string
  24. 20:46Resizing a string
  25. 23:01railsbench
  26. 23:33rdoc generation
  27. 25:32Resizing objects
  28. 26:07Shrinking RVALUE
~/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.