Adventures in Garbage Collection: Improving GC Performance in our Massive Monolith - Shopify
Apr 6, 2023

Summary
This post details specific tuning of Ruby's garbage collector to reduce latency in Shopify's monolith. It addresses major GC triggers like `:oldmalloc` by setting a high limit and `:nofree` by implementing finely-grained preallocation of heap slots using a custom hack and later a Ruby feature. The work involved extensive logging, metric analysis, hypothesis formation, and experimentation, leading to significant reductions in GC time and improved tail latency.
More from the Ruby Execution Models and Threading trail
- Optimizing Ruby’s Memory Layout: Variable Width Allocation - Shopify
- To Thread or Not to Thread: An In-Depth Look at Ruby’s Execution Models - Shopify
- Diggin’ and Fetchin’ with TruffleRuby - Shopify
- Sam Saffron AMA: Performance and Monitoring with Ruby - Shopify
- How to Write Fast Code in Ruby on Rails - Shopify