Zeitwerk Internals
summary
Zeitwerk is the Ruby autoloader that scans configured root directories just one level deep, sets autoloads for files and directories, and defers loading until Ruby triggers those autoloads; it intercepts require to do bookkeeping, defines missing modules on the fly and then descends into that branch, and implements reloading by removing constants and entries from loaded_features. Implementation details: ~1k LOC, per-loader deterministic inflector, tracepoint on class event, and uses absolute paths for require for speed.
AI-written summary · about
chapters (6)
- 0:00Introduction to Zeitwerk
- 2:35Ruby constants and namespaces
- 12:57How Zeitwerk sets autoloads
- 21:15Triggering autoloads in Ruby
- 29:28Reloading and eager loading
- 33:47Summary and Q&A
related talks
57mZeitwerk Internals
58mZeitwerk: A new code loader for Ruby
42mZeitwerk: A new code loader
01h 02mOpening Keynote: The Journey to Zeitwerk
44mrequire() bombed my multi-threaded app!
47mConstant autoloading in ruby on rails
45mClass Reloading in Ruby on Rails: The Whole Story
29mHow to Load 1m Lines of Ruby in 5s
