"The View Is Clear from Here"
summary
Walks through how Rails Action View compiles ERB into Ruby methods (ERB backends: erubi is fastest), shows microbenchmarks: naive compile+eval ~27k renders/s, caching compiled source ~63k/s, turning templates into dynamically defined methods ~1.4M renders/s (≈52× faster). Demonstrates surprising results: fragment caching can be ~5× slower because cache key computation outweighs render cost. Recommends ERB -> methods strategy, avoid instance variables in templates, keep locals consistent and notes a Github precompile effort and a cache can be slower caveat.
AI-written summary · about
chapters (14)
- 0:00Introduction
- 1:11About the speaker
- 3:58Ruby and logic
- 7:10Rails view layer
- 9:35ERB templates
- 12:01Capturing blocks
- 14:12Optimizing view performance
- 18:23Instance variables vs locals
- 22:44Pre-compilation issues
- 25:51Ambiguous rendering behavior
- 30:54Predictable performance
- 33:33Caching and benchmarking
- 36:47Proposed optimizations
- 39:30Conclusion and Q&A
related talks
54mThe View is Clear From Here
42mRender It! A Deep Dive into ActionView and Template Engines
38mRethinking the View Layer with Components
59mClosing Keynote
32mIntroducing ReActionView
42m3x Rails: Tuning the Framework Internals
58mPanel Discusion - Performance problems in Rails applications
37mEncapsulating Views
