ZOMG WHY IS THIS CODE SO SLOW?
summary
A rewrite of Arel turns an O(n^2) linked‑list SQL generator into an O(n) AST + visitor and cuts end‑to‑end time roughly in half; profiling uses perf‑tools.rb, ruby‑prof and mini‑test‑benchmark to discover hotspots (4,000 vs 2,000 calls to Time.now per 1,000 iterations) and many short‑lived objects causing GC pressure; visualization via Graphviz drives a structural redesign, garbage and method calls drop, flog/flay scores fall (≈2500→1800 and 684→420) and new features like SQL parse‑tree output become possible.
AI-written summary · about
chapters (22)
- 0:00BLUE BLUE BOX GROUP, LLC
- 1:13X-TREME RUBYCONF!!!!!
- 6:47Code Analysis
- 7:27Relational Algebra
- 9:39Getting Started
- 9:55Prepared Statement Caching
- 11:00Motivation
- 14:17Performance Degraded
- 14:28Benchmarking
- 14:41For Performance
- 14:57For Clean Code
- 15:12Measurement is Paramount
- 19:47Method Call Analysis
- 23:01Superficial Improvements
- 28:23Proc Activation
- 30:00Explicit Block Parameters
- 32:17return value caching
- 35:14Data Structure Analysis
- 35:47Visitor Pattern
- 39:17Mathematical Representation
- 42:10Deep Improvements
- 42:576 Weeks Later...
related talks
42m3x Rails: Tuning the Framework Internals
17mWrangle Your SQL With Arel
31mThe AST Galaxy to the Virtual Machine Blues
21mActiveRecord can't do it? Arel can!
01h 12mOpening Keynote – Yukihiro 'Matz' Matsumoto
42mii hidden gems
33mRuby the Hard Way: Writing Bytecode to Optimize Plain Ruby
01h 09mFlash Talks
