~/talk

Making .is_a? Fast

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

Claim: Ruby's is_a? family used to cost 2–4% of runtime in real apps and scan long ancestor chains (one model had 305 ancestors, the repo had 92,000 classes). Using stackprof rbspy Linux perf and Railsbench, author implements and benchmarks alternatives, ships a constant time depth-table lookup in C with de‑duplication to cut memory (6.5MB → ~1MB) and lands the change and YJIT assembly in Ruby 3.2, giving a clear, measured win.

AI-written summary · about

  1. 0:00Introduction
  2. 3:37Profiling .is_a? impact
  3. 7:58How .is_a? checks ancestry
  4. 11:55Optimizing .is_a? challenges
  5. 14:09Hash-based ancestor lookup
  6. 17:23Skipping module ancestors
  7. 19:31Array-based linear scan
  8. 21:43Shared ancestor arrays insight
  9. 24:09Memory optimization for ancestors
  10. 25:36C implementation results
  11. 26:39Conclusion
~/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.