High Performance Ruby
summary
Shows concrete wins: running JRuby on JVM plus invokeDynamic turns dynamic calls into inlines and yields about an 800% improvement over early JRuby and roughly 3x performance gains from JVM upgrades alone. Identifies exact pain points — eval, singletons/extend and constant redefinition blow caches; ObjectSpace bookkeeping triggers massive GC — and concrete fixes: precreate classes, freeze constants, avoid chained allocations, use persistent structures (Hamster). Real benchmarks include base64, richards, neural network, mandelbrot and a red‑black tree where pure‑Ruby runs ~3.96s.
AI-written summary · about
chapters (39)
- 0:00Start
- 1:39Optimize What?
- 2:42Ahh, Benchmarks
- 3:34Versus Python?
- 4:06Clojure?
- 4:31JavaScript?
- 4:53Maybe Java?
- 5:05Hell, just write it in C!
- 6:17Unnecessary Work
- 8:23Why Things Run Slow
- 9:40Two Key Areas
- 11:15Method Caching
- 12:07Inlining
- 12:23Inline foo into invoker
- 12:39Inline invoker into loop
- 12:51Value is transient
- 13:04Loop does nothing
- 13:37Cache Busting
- 15:18Dynamic Invocation
- 17:43Fixing eval
- 19:48Object#extend
- 21:22Fixing Singletons/ #extend
- 23:49Constant Lookup
- 24:15Cache Invalidation
- 25:00Cache-Busting
- 26:18Fixing Constants
- 27:11Ruby Loves Objects
- 27:42Culprits
- 28:33Fixing Literals
- 29:38Fixing Concat/Copy
- 30:09Fixing Enum Chaining
- 30:56Case Study: JRuby
- 32:02Leverage the JVM
- 33:04ObjectSpace
- 34:35Performance
- 34:49InvokeDynamic
- 37:00smooth_sort
- 38:02rbtree Extension
- 40:11The Lesson








