Optimizing Ruby: Building an Always-On Production Profiler
summary
Datadog’s Ruby continuous profiler is an always-on production sampler that collects CPU, wall time, allocations, GC and heap-live objects with low overhead by sampling every 10 ms from a background C thread interrupting workers via Unix signals and RB_postponed_job_trigger. Implementation mixes C and Rust, shipping a C + Rust binary gem (Linux-first) that compresses pprof output. Real fixes include spotting a regex hotspot in a repo with 50,000 branches 130,000 tags and eliminating a duplicated ObjectSpace check that doubled cost.
AI-written summary · about
chapters (16)
- 0:00Introduction to Ruby profiler
- 1:13Speaker background and Datadog
- 3:40Why build a new Ruby profiler
- 5:26Types of profiling data
- 10:20How CPU and wall time work
- 12:49Sampling for low overhead
- 13:31CPU and wall time details
- 16:39Handling the GIL in Ruby
- 17:42Adjusting sampling overhead
- 18:03Garbage collection profiling
- 19:27Tracking object allocations
- 20:32Detecting memory leaks
- 21:59Challenges in profiling
- 24:50Using Rust in Ruby gems
- 26:58Why always-on production profiling
- 29:47Learning from profiling data
related talks
37mThe Future of Ruby Performance Tooling
26mHow a Ruby profiler works: Stackprof under a microscope
43mReal World Ruby Performance at Scale
34mMetric Driven Development with Ruby on Rails
24mDIY::Thread.profile -- Light-Weight Profiling in Pure Ruby
42mDebugging Ruby
34mHow to optimize Ruby internal.
18mPerformance Optimization in Ruby
