chore(B5e-v2): plan to close memory gap with Luerl#238
Closed
davydog187 wants to merge 1 commit into
Closed
Conversation
Captures the follow-up identified during B5a-v2 review: dispatcher allocates 263 MB on fib(25) vs Luerl's 227 MB, with ~80% of the deficit attributable to :erlang.setelement/3 copying the register tuple on every opcode. Approach: replace immutable tuple regs with process-dict-backed mutable storage scoped to the dispatcher only. The interpreter and the bytecode format stay unchanged. Targets ≤130 MB on fib(25) (soft gate) and Luerl parity (stretch). Blocked on B5a-v2 (PR #237) landing.
Contributor
Author
|
Withdrawing this plan after empirical investigation. The 'memory gap with Luerl' (263 MB vs 227 MB allocated on fib(25)) is cumulative bytes allocated, not retained heap. Peak resident memory on fib(28) is 136 KB — the BEAM is already destructively updating the register tuple in our |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
B5e-v2: Dispatcher mutable register storage
Plan:
.agents/plans/B5e-v2-dispatcher-mutable-regs.mdContext
B5a-v2 (PR #237) closed most of the memory gap with Luerl on fib(25):
We're 1.25x faster than Luerl on time but still 1.16x heavier on memory. The deficit traces directly to
:erlang.setelement/3copying the register tuple on every register write — ~80% of dispatcher allocations.Proposed approach
Replace the dispatcher's immutable tuple register file with process-dict-backed mutable storage. Scope is dispatcher-only — the interpreter and the bytecode format are unchanged. Each
setelementbecomesProcess.put({:disp_reg, idx}, value). Frame save/restore allocates one tuple per call (down from N tuples per N register writes).Projected savings on fib(22):
Gates
Key risks (documented in the plan)
Lua.eval!calls via:native_funccallbacks must snapshot/restore process-dict keys cleanly.Out of scope
:arraymoduleStatus
blockedon B5a-v2 (PR #237) landing. Once merged, this plan is ready to ship.Verification