Achieving Fast Method Metaprogramming: Lessons from..
summary
MemoWise is a memoization gem built with benchmark-driven development using benchmark-ips, deliberate GC control and concrete microbenchmarks; it replaces block-based define_method with module_eval string generation, flattens and special-cases keys to cut allocations, and uses arrays plus a sentinel array for nil-distinguishing. Benchmarks show large speedups for zero- and one-argument methods, modest gains elsewhere, and a ~3% tradeoff point when falsy results are common; the gem ships and the optimizations measurably improve the data pipeline.
AI-written summary · about
chapters (9)
- 0:00Start
- 4:28Memoize Snippet
- 6:26Experiments
- 8:27Hypothesis
- 9:42Module Eval
- 16:03Example Code
- 19:31Sentinel Array
- 24:09Truthy Optimization
- 26:56Ebook on Ruby Garbage Collection








