vm: read a call's chunk metadata from one per-chunk record (fibonacci(30)) #8
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Goal
A call in the VM reads the callee's chunk metadata from one per-chunk record whose address is computed once per call, instead of five separate
header(image, chunk, word)reads that each recomputeheadersAddress + 8 * (chunk * headerWords + word). This is the second of the four speed steps of VM.md "Speed, the next steps"; the issue is narrowed to it (see "Scope after refinement").Source
headerWords), the return record of four words below a frame.fibonacci(30)about 0.19 s, the number to beat; the method is there.Scope after refinement
Placesteps as words of the image) is already built:appendPlace,placeAtandresolvePlaceofcompiler/src/vm/interpret.trbread a place's steps as words by address, since the VM runs on every worker of the pool (commit94c4a99e). VM.md section 10 is stale there; the correction is part of #165.fibonacci(30)retains nothing, so #164 cannot be measured on it.What to change
All in
compiler/src/vm/interpret.trb(headerWords,imageOf,header, the.Call,.CallClosure,.CallWitness,.Returnarms ofexecuteLoop,ensureFrame). The image is laid out in memory at load byimageOf; it is not serialized (vm/embed.trbwrites chunks, not the image), so the bytecode format and the embedded program's version token do not change.Acceptance criteria
headersAddress + 8 * headerWords * chunk, computed once on entry to a chunk) and reads the fields a call and a return need (code start, frame words, places start, first parameter, parameter count) at constant offsets from it;.Call,.CallClosure,.CallWitnessand.Returnno longer callheader(...)with a chunk index for them. The return record in the word stack may keep the chunk index (the debugger, the stack-overflow site andnoteFramesuse it) or hold the record address, whichever keepscodeStartOfand the debugger unchanged.ensureFrametakes the frame size from the same record (no second index computation for the same callee).torb ir --bytecodeoutput (snapshots incompiler/tests/bytecode.test.trb) is identical, because the emitter is untouched;tools/conformance.sh --vmand the.workersprograms, the debugger sessions (tests/debug/) and the sandbox programs (vm-only/) are green in tier A and tier B of the forge CI.Machineaddition: onlyinterpret.trband, for the stale paragraph, nothing else (the VM.md text is #165).fibonacci(30)is to be re-measured by #165 against the previous nightly; the worker does not claim a speed-up it did not measure.Seed impact
None. No syntax change, no new native, no driver flag, no std name looked up by string. If the work turns out to need one, stop and file an owner decision instead of refreshing a seed.
Size and commits
One PR, one Conventional Commit:
perf(vm): read a call's chunk metadata from one record. Touchescompiler/src/vm/interpret.trbonly.Implementer
opus/high (
compiler/src/vm, the interpreter hot path). CI only for the gates (tier A and tier B, because the interpreter runs the whole conformance suite); locally atorb format --checkof the file and one quick test.Collisions
runtime/sandbox.c,runtime/io.c,std/sandbox, conformance programs and docs - no shared file. If its tests expose an interpreter defect in the sandbox/budget code ofinterpret.trb, a trivial rebase is the worst case.runtime/stream.c,runtime/tests/, conformance programs) and #6 (pool benchmark:runtime/task.c,benchmarks/,CONCURRENCY.md) share no file with this issue.executeLooparms later: land this first, #163 rebases on it.Dependencies
None open for this step. Follow-ups: #163, #164 (owner decisions), #165 (measurement).
[loop:torbscript] intake: in scope (author orion, label loop). Implements the four open speed steps of VM.md, each measured against fibonacci(30) (section 8); no collision with CONCEPT "Open Questions". Touches the VM and image format (opus/high worker); the image-format steps may touch the seed, to settle in refine. Likely to be split per step. Release freeze for 0.1.0 (2026-10-06) holds new PRs, next: refine (queued, buffer >= 2 ready)
[loop:torbscript] claim refine by session:loop-torbscript-20261008 until 2026-10-08T00:30:21Z
[loop:torbscript] release refine: the earlier refine worker died with the gateway recreate (claim expired without a result). New claim follows.
[loop:torbscript] claim refine by session:loop-torbscript-20261008 until 2026-10-08T02:33:26Z
vm: the next speed steps measured againstto vm: read a call's chunk metadata from one per-chunk record (fibonacci(30))fibonacci(30)[loop:torbscript] refine: issue narrowed to the second speed step (one per-chunk record for a call) and set
ready. Step 4 (place steps as image words) is already built, so only VM.md is stale; step 1 became #163 and step 3 #164, each with an owner decision comment (newMachinenatives mean a seed refresh;fibonacci(30)cannot show step 3 at all); the measured numbers and the VM.md update became #165, because workers never run a release build. No seed impact, one commitperf(vm): ...,compiler/src/vm/interpret.trbonly, no collision with #5, #6 or #7. Implementer: opus/high. The owner decisions are comments only; noquestion_asktool was available to the refine worker, so the tick should file the blocks for #163 and #164. Worker usage ~120000 tokens, next: implement[loop:torbscript] claim implement by session:loop-torbscript-20261008 until 2026-10-08T06:38:37Z
[loop:torbscript] implement: one commit
perf(vm): read a call's chunk metadata from one record(onlycompiler/src/vm/interpret.trb): the loop holds the running chunk's header record address (recordOf), computed on entry to a chunk and wherever the image is taken anew;.Call,.CallClosure,.CallWitnessand.Returnread code start, frame words, places, first parameter and parameter count at constant offsets, the parameter words through oneparametersOfaddress, andensureFrametakes the callee's record. The return record keeps the chunk index, socodeStartOf,noteFramesand the debugger are unchanged. No seed impact, no new native. Forge CI of the PR green (bootstrap, tier A including the debugger sessions, playground, C agreement); tier B is skipped on pull requests that do not touchir/,backend/,runtime/,tools/or.forgejo/(ci.yml rule), soconformance.sh --vmruns on the push of the landed commit to main. Speed not measured here, left to #165. PR #166, worker usage ~150000 tokens, next: review