Repository navigation
Conversation
Previously the frame stored SSA values in two tiers: a dense slots array for most values plus a lazily-created cells map fallback used only for Alloc results (Allocs were excluded from the slot layout). This split was a common source of confusion. Every SSA value that can be read/written is known at frameLayout time, so Alloc can be slotted too: re-executing an Alloc still allocates a fresh addressable object via runAlloc; the slot merely holds the latest pointer, and earlier objects stay alive through other references. Closures are unaffected because runMakeClosure snapshots values into fresh Cells rather than pointing at frame storage. With Allocs slotted, the cells map is provably dead (verified by asserting no writes across the full -race suite), so it is removed. cell/setCell/ bindCell now use slots exclusively; an unslotted value is a hard invariant violation. Result (benchstat, n=6, int-heavy workloads): time geomean +0.64% (a couple arithmetic microloops +3-4%, several others slightly faster), allocs geomean -5.58% (SliceSum -17.65%, BubbleSort -18.75%) from dropping the lazy map. Full 'go test -race ./...' passes; lint/gosec clean. Co-authored-by: t04dJ14n9 <t04dJ14n9@users.noreply.github.com>
Per the decision to prioritize minimal, understandable code over peak
throughput on synthetic numeric loops, this deletes the entire fast-path
('block plan') layer and leaves a single, uniform dispatch:
- Delete fast_plan.go (typed int/bool fast instrs, fast phis, fused
IndexAddr plans, whole-block fast loop).
- runFrame is now one loop: resolve block Phis, then visitInstr per
instruction. runBlockPhis has only the generic path.
- frameLayout computes just the slot index (no slotKinds, blockPlans, or
fusedIndexAddr precompilation).
- Cell drops the typed cache (fastInt/fastBool/fastDirty); setCell/bindCell
write Cell.Value directly; setSlotValue/materializeSlot are gone.
- Remove the fused IndexAddr optimization (fusableIndexAddrConsumer,
tryRunFusedIndexAddr); the generic IndexAddr/Load/Store path handles it.
isPlainIntSliceType stays (native int-slice value representation).
- Drop the fast-plan-internals tests; keep the behavior tests.
Net -895/+21 lines. Full 'go test -race ./...' passes; lint/gosec clean.
Performance trade-off (benchstat, int-heavy loops): ~3.6x geomean slower
(e.g. ArithmeticSum +381%, BubbleSort +604%). These are synthetic numeric
kernels, not gig's target rule-engine workloads; external-call/host paths
are unaffected. Variable storage remains a single []Cell per frame.
Co-authored-by: t04dJ14n9 <t04dJ14n9@users.noreply.github.com>
t04dJ14n9
marked this pull request as ready for review
August 13, 2026 17:15
After the fast-plan removal, frameLayout held only 'index', so the struct wrapper and the separate newFrameWithLayout helper were pure indirection. frameLayout now returns map[ssa.Value]int directly and newFrame builds the frame inline. No behavior change. Co-authored-by: t04dJ14n9 <t04dJ14n9@users.noreply.github.com>
Follow-up cleanups found by a code review of the minimized interpreter, all behavior-preserving (full -race suite + lint/gosec green): - frame: drop the write-only freeVars field (free vars are bound via the callSSA parameter) and the now-unneeded newFrame freeVars parameter. - callSSA: drop the redundant 'fr.cancelTicks = 0' reset (newFrame always returns a freshly-zeroed frame; a leftover from frame pooling). - visitInstr: remove the unreachable *ssa.Phi no-op case (runFrame resolves and skips Phis before dispatch). - runBlockPhis: drop the redundant re-assertion in the second loop; indices below phiCount are leading Phis by construction. - callBuiltin: print/println built a []any that was immediately discarded; reduce to a plain no-op return. - runRange: remove the dead sentinel setCell (the Range value is never read; iteration flows through fr.iters). - Refresh stale comments (drop 'hot path', 'vertical slice', 'Phase 6.x'). Net -22 lines. Co-authored-by: t04dJ14n9 <t04dJ14n9@users.noreply.github.com>
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.
Goal
Make the interpreter minimal and easy to understand, accepting reduced throughput on synthetic numeric loops. Breaking internal changes are fine. Variable storage is a single
[]Cellper frame throughout.1. Unify variable storage into a single
[]CellPreviously the frame used a dense
slotsarray plus a lazycellsmap (the map held onlyAllocresults). Now every SSA value — includingAlloc— gets a slot and thecellsmap is removed (proven dead by asserting no writes across the full-racesuite).cell/setCell/bindCellare slot-only; closures are unaffected becauserunMakeClosuresnapshots into freshCells.2. Remove the fast-plan ("block plan") machinery
Deleted the entire fast-path layer that made the hot loop hard to follow:
fast_plan.go(typed int/bool fast instructions, fast phis, fusedIndexAddrplans, whole-block fast loop) — deleted.runFrameis now a single loop: resolve blockPhis, thenvisitInstrper instruction.runBlockPhishas only the generic path.frameLayoutreduced to a plainmap[ssa.Value]int(no struct wrapper, noslotKinds/blockPlans/fusedIndexAddr).Celldrops the typed cache (fastInt/fastBool/fastDirty);setSlotValue/materializeSlotgone.IndexAddroptimization; the generic path handles it. (isPlainIntSliceTypestays — native int-slice value representation.)3. Remove post-simplification vestiges (review follow-up)
A comparative review of the minimized code found leftover dead/vestigial bits, all behavior-preserving:
frame.freeVarsfield and the unneedednewFrameparameter;cancelTicksreset (leftover from frame pooling);*ssa.Phicase invisitInstrand a redundant re-assertion inrunBlockPhis;print/printlnbuilt a[]anythat was immediately discarded → plain no-op;setCellinrunRange;Overall: ≈ −960 net lines;
fast_plan.goremoved;runFrame/frameLayoutdrastically simplified.Performance trade-off (benchstat, int-heavy loops)
~3.6× geomean slower on synthetic numeric kernels (BubbleSort +604%, ArithmeticSum +381%, GCD +145%). gig's target rule-engine workloads (field access, comparisons, string/host calls) run through
visitInstr+ the host bridge and are unaffected. Deliberate simplicity-over-microbench-throughput trade.Validation
go test -race ./...pass (root +cmd/gig) ·golangci-lint0 issues (root + CLI) ·gosec0 issues ·go vetclean.