~/talk

The Curious Case of the Bad Clone

Talkat RailsConf 2021 · 2021-04-12..04-15· [ruby, ruby-on-rails]
slides:none on file

A two-line Sorbet sig triggers a 150% slowdown by causing about 1,600 method_added calls during cloning. Investigation uses CPU profiles, bundle open edits, puts and binding.pry, rails runner, and object space TraceObjectAllocations to find an unnamed singleton-class clone path. A minimal reproducer and Rails bug-template script isolates the issue, a PR with Alan Wu changes the clone/attach guard, and the fix lands in Ruby 3.0 (and is backported to 2.7).

AI-written summary · about

  1. 0:00Introduction
  2. 1:43What is Sorbet
  3. 3:11Runtime magic with method_added
  4. 7:27Performance regression
  5. 11:28Mystery of cloned methods
  6. 14:02Kernel.clone and Singleton behavior
  7. 20:47Root cause in Rails sharding
  8. 27:37after_find and object cloning
  9. 33:15Reproducing the bug
  10. 41:41Singleton class cloning
  11. 46:24Fixing Singleton class cloning
  12. 50:21Verifying fix in Ruby 3
~/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.