Rails and the Ruby Garbage Collector: How to Speed Up Your Rails App
summary
Explains how Ruby’s mark‑and‑sweep, generational GC works, what to measure with GC.stat metrics, and which knobs actually change behavior like GC_HEAP_INIT_SLOTS and old malloc limits. Reports real results: tuning cuts average GC time per request ~50% and 99th GC time ~80%, translating to ~13% faster average responses (25% faster 99th). Introduces the Autotuner gem (github.com/shopify/autotuner) that analyzes between requests and emits concrete env var tuning suggestions.
AI-written summary · about
chapters (18)
- 0:00Introduction to talk
- 0:25What is a garbage collector
- 1:29Ruby object memory structure
- 3:55How Ruby allocates objects
- 4:59Mark and sweep phases
- 8:29Generational garbage collection
- 10:13Major vs minor GC cycles
- 12:00Write barriers and remember set
- 14:52Sweeping phase explained
- 15:56Compaction in Ruby GC
- 17:20Collecting GC metrics
- 21:34Tuning the garbage collector
- 23:19Out-of-band garbage collection
- 25:11Real-world tuning results
- 26:17Ruby 3.3 GC improvements
- 28:41Introducing Autotuner gem
- 29:43Testing tuning at Shopify
- 32:08Q&A and closing
related talks
21mUnderstanding Garbage Collection in Ruby
42mTweaking Ruby GC Parameters for Fun, Speed, and Profit
29mImprove Performance Quick and Cheap: Optimize Memory and Upgrade to Ruby 2.1
38mWhy I am excited about Ruby 2.1?
35mThe Hitchhiker's Guide to Ruby GC
01h 15mSpeedupRails, Speedup Your Code
30mBuilding the Next-Generation Garbage Collector in Ruby
34mUnder the Hood of Ruby's Generational Garbage Collector
