~/talk

A Muggle's Guide to Tail Call Optimization in Ruby

Talkat RubyConf 2015 · 2015-11-15..11-17· [ruby]
slides:none on file

Claim: Ruby 1.9.2 has TCO but disabled; the VM actually reuses a single stack frame instead of growing one per recursive call, so tail recursion becomes a loop and avoids SystemStackError until ≈10,000 frames. Tools demonstrated: flip two flags in MRI, use RubyVM::InstructionSequence or the TCO method gem to enable it per-compile. Tradeoffs: set_trace_func and some debugging/gems break, Rails test runs show failures, and real-world speedups are modest though memory pressure and GC can improve.

AI-written summary · about

  1. 0:00Introduction
  2. 3:28What is a tail call
  3. 8:07What is tail recursion
  4. 12:00What is tail call optimization
  5. 16:32How to enable tail call optimization
  6. 23:46Benefits of tail call optimization
  7. 26:58Limitations of tail call optimization
  8. 29:45Where to find Danny
  9. 30:43If you use the mixin
  10. 31:56Stack errors
  11. 32:46Recursive strategies
  12. 33:15Benchmarks
  13. 33:56How to tell if a method is optimized
  14. 35:21Dependencies
  15. 36:01New Relic
  16. 36:18What do I think would need to happen
  17. 36:45Best way to do it
  18. 37:16Making it easier to explore
  19. 38:21Other VM optimizations
  20. 39:10JRuby
  21. 40:02Ruby Test Suite
  22. 40:31When to use it
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.