Parent: #48
Profile evidence
A symbolized GC-enabled Fibonacci run executes bytecode. The hot path included vm.runChunk, buildActivation, and repeated global identifier lookup. buildActivation retained a new Activation, Frame, local slot buffer, operand stack backing, and handler backing in the Context arena for every call.
A 1,000-job diagnostic reached 11 GiB physical footprint with a 28.4 GiB reported peak before throwing. On an identical 50-job process run, the cached baseline consumed 3.36 GiB maximum RSS.
Scope
- Reuse completed VM activations only when their frame did not escape into a closure.
- Retain operand/handler capacity and reset all logical state before reuse.
- Never recycle a captured frame or expose pooled stale values to GC tracing.
- Release activations on return, tail-call replacement, unwind, and error teardown paths.
- Add a focused bounded-allocation regression plus closure and deep-recursion coverage.
- Measure process-isolated before/after Fibonacci time and RSS.
- Run focused semantic/GC/no-GIL/TSan checks, commit with issue references, and push to main.
- Require the final combined Actions gate to pass.
Result
Implemented in eda34f5. Seven process-isolated 20-job samples improved from a 486.112 ms median to 409.844 ms (1.186x). The 50-job optimized run used 6.9 MiB maximum RSS versus 3.36 GiB for the cached baseline.