New Ruby 2.1 Awesomeness: Pro Object Allocation Tracing
summary
Ruby 2.1 exposes ObjectSpace.#trace_object_allocations so code reports file line class and method for each allocation; two gems allocation_stats and rack-objspace-stats aggregate and group those sites, support trace_object_allocations start/stop, burn-one and times=10 runs, and an interactive JSON view. Examples: dumping two strings into YAML shows 38 strings from visitor and 12 arrays; a tiny Rails 3.2 page expects ~100 strings but reports 756 strings; fixes include concat instead of +=, freezing or memoizing literals, and middleware output that pinpoints hot lines.
AI-written summary · about
chapters (9)
- 0:00Intro
- 1:29Object Allocation Tracing
- 3:38Why are we doing this
- 4:29Aggregation
- 11:52Rack Allocation Stats
- 16:12How to allocate less
- 17:17String Freeze
- 19:52Rails Allocation
- 24:32Conclusion
related talks
30mRuby Objects: A Walkabout
53mRuby.inspect
37mThe Future of Ruby Performance Tooling
49mRabbit Hole: Garbage Collection and Ruby's Future
24mRuby Performance Secrets and How to Uncover Them
43mCat Care and Maintenance
37mWhat’s happening in your Rails app? Introduction to Introspection features of Ruby
42mDebugging Ruby
