Loading…
Sam Saffron AMA: Performance and Monitoring with Ruby
2023-10-18
- Source
- Shopify
- Published
- Added to Yomu
Summary
Sam Saffron discusses Discourse’s approach to Ruby performance and monitoring, arguing that production memory constraints matter more than isolated microbenchmarks for many deployments. He favors clear code and selective optimization, sometimes bypassing ActiveRecord with MiniSql on performance-sensitive paths rather than broadly sacrificing Ruby’s readability. Discourse keeps performance under continuous observation, and Saffron describes budgets for dependencies, boot time, and high-profile pages, including alerts for query-count regressions. He identifies memory leaks as especially difficult to diagnose, describes bisecting an application to isolate a V8-Ruby interop leak, and says MRI remains the only feasible runtime for Discourse while memory profiling and analysis tooling remain substantially behind Java and .NET.
Context
The discussion addresses Ruby’s performance reputation, the risk of prioritizing microbenchmarks over production bottlenecks, and Discourse’s particular sensitivity to memory usage because it is intended to run on inexpensive, memory-constrained servers. It also covers gaps in MRI’s memory-profiling and analysis tooling.
Approach / What changed
Discourse monitors performance continuously through graphs and budgets covering dependencies, boot time, and high-profile pages. Saffron describes selectively replacing ActiveRecord with MiniSql, using alerts for query-count regressions, and isolating memory leaks by removing and restoring application sections until the responsible area is found.
Takeaways
- Discourse’s largest performance pain is memory rather than CPU; the difference between running on 512MB and 1024MB systems affects adoption, while hosting also sees memory issues.
- Saffron may use MiniSql instead of ActiveRecord on performance-sensitive flows, but generally preserves readable Ruby and changes patterns only for clarity or when performance requires it.
- MRI memory tooling lacks full allocation backtraces and strong visualization of managed and unmanaged memory; Saffron compares it unfavorably with Java and .NET tooling.