Repository navigation
Conversation
The .golangci.yml disables the 'unused' linter for internal/interp and for all test files, which hid several genuinely-unreferenced private symbols. Removed (verified unused via staticcheck U1000 and grep): - internal/interp: (*program).reflectFromCellValue, deferRecord.pos field, and the unused local recvSlot type in runSelect. - tests: orphaned helpers runDiagProgram, newBoundaryRejectionRegistry, hostAcceptAny, and the embeddedHostImportPath const. Also fixed a stale doc comment (reflectValue was documented as composeReflectValue). No behavior change; full -race suite still passes. Co-authored-by: t04dJ14n9 <t04dJ14n9@users.noreply.github.com>
Several package/function comments described the abandoned bytecode-VM design and migration 'Phase' milestones for features that are fully implemented (interpreter dispatch, defer/panic, goroutines, host bridge), and one comment claimed debug_dump.go avoids importing io while it clearly uses it. Rewrote them to match the current v2 SSA interpreter. Also removed dead code: - program.fset (written at construction, never read). - debug_dump.go: dead '_ = os.Stderr' and its now-unused os import. No behavior change. Co-authored-by: t04dJ14n9 <t04dJ14n9@users.noreply.github.com>
callHostFunc and callHostFuncDirect contained identical blocks resolving a function's package path from its SSA package with a type-checker-object fallback. Extracted a small pure hostPkgPath(fn) helper. Co-authored-by: t04dJ14n9 <t04dJ14n9@users.noreply.github.com>
runCall (invoke, direct-function, and indirect-closure paths) and runDefer each repeated the same make+readValue loop to turn SSA arguments into interpreter values. Factored into a single (*program).readArgs helper. No behavior change. Co-authored-by: t04dJ14n9 <t04dJ14n9@users.noreply.github.com>
The whole-block fast path carried accidental complexity that made the two execution paths (generic vs fast) harder to follow: - fastOp/fastOpKind wrapped a single fastInstr behind a one-variant tag. Replaced []fastOp with []fastInstr; runFastBlock iterates directly. - runFastBlock/runFastInstr returned an always-nil []value.Value and the callers had dead 'contReturn' branches (fast instrs only continue or jump, never return). Dropped the value tuple and the dead branches. Benchmarked before/after on int-heavy workloads (ArithmeticSum, FibIterative, Sieve, BubbleSort, NestedLoops, GCD, SliceSum): no change beyond noise. Full 'go test -race ./...' passes. Pure clarity refactor; the whole-block fast path itself is retained because it is worth 10-29% on those workloads (and the typed fast path overall ~3-6x). 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.
Summary
A code-quality evaluation of
gigplus safe, verified cleanups, and an evaluation of the interpreter's fast-path ("block plan") design. The codebase already passes a strictgolangci-lintconfig (default: all) with 0 issues,go vetclean,gosecclean. All changes here are behavior-preserving (full-racesuite green) and, for the hot-path change, benchmark-neutral.Commits
unusedis disabled forinternal/interp/and test files):reflectFromCellValue,deferRecord.pos, unusedrecvSlot, orphaned test helpers; fixed a mislabeled doc comment.bytecode.CompiledProgramreference, a comment claimingdebug_dump.goavoids importingio(it uses it); removed deadprogram.fsetand_ = os.Stderr.hostPkgPathto dedupe package-path resolution.readArgsfor SSA-argument materialization repeated 3× inrunCalland once inrunDefer.fastOp/fastOpKindsingle-variant wrapper (use[]fastInstr), dropped the always-nil[]value.ValuefromrunFastBlock/runFastInstr, and removed deadcontReturnbranches in the fast paths.Fast-path ("block plan") evaluation
The block plan has two tiers: a per-instruction typed fast path (predecoded int/bool BinOp/If/Jump + fused int-slice IndexAddr) and a whole-block tight loop (
runFastBlock) for blocks that are entirely fast and end in If/Jump. Both were suspected of being confusing/redundant. Benchmarks (int-heavy workloads, this VM) settle it:Conclusion: do not remove it. The typed fast path is worth ~3–6× on exactly the workloads that are already gig's weak spot, and the whole-block tier adds a further ~10–29%. The right response to the confusion is unification/cleanup, not deletion. Commit 5 removes the accidental complexity at zero perf cost.
Recommended follow-up (separate, MED-risk PR): unify the three parallel per-instruction arrays (
fastInstrs,fastIndexAddrs,fusedIndexAddrConsumers) plus the raw SSA loop into a single decoded op stream per block, where each op is either a typed fast op or a "generic SSA" fallback, executed by one loop (keeping an "all-fast" tight-loop variant to preserve the whole-block speedup). Also fold/remove the test-onlyframeLayout.fusedIndexAddrmap (duplicates the per-block consumer slices). This is the true "unify normal + fast path" and deserves its own benchmarked PR.Validation
go test -race ./...pass ·golangci-lint0 issues ·gosec0 issues ·go vetclean · fast-path change benchmarked before/after with no change beyond noise.