Flattening Recursion with Fibers
summary
Uses Ruby fibers to linearize nested around-callbacks in Mongoid by creating a fiber per embedded child and resuming them in sequence so the before yield after ordering stays correct. Demonstrates avoiding a SystemStackError on records with thousands (1,000s to 10,000s) of embedded documents, moves per-frame allocation from stack to heap, and integrates the proof‑of‑concept into run callbacks inside mongoid where it successfully prevents stack overflow while shifting memory pressure to the heap.
AI-written summary · about








