feat(interp): add Pool for multi-goroutine interpreter use#35
Conversation
Interpreter holds per-instance mutable runtime state (frames, stack, heap, JIT buffer) and is not safe to share across goroutines. Pool lets callers share an immutable Program while borrowing one Interpreter per goroutine via Get/Put or Run(ctx, fn). Backed by a bounded channel with explicit Close() so mmap'd JIT buffers are always released; Reset is called between borrows to clear runtime state.
PR Review — feat(interp): add Pool for multi-goroutine interpreter useDecision✅ Ready to merge Merge Readiness SummaryThis PR is merge-ready. It adds a focused, well-tested feature for concurrent VM use by enabling multiple goroutines to share a single AnalysisScope Control
Correctness
Test Coverage
Documentation
API Design
Architecture & Compatibility
Risk & Validation
Readiness Checklist
Final RecommendationMerge — This is a well-executed feature with proper concurrency handling, comprehensive tests, and clear documentation. Generated by Claude Code |
- Reorder methods Run/Get/Put/Close so callers appear above callees (docs/coding-patterns.md §1.3). - Split Get into isClosed/tryRecv/tryCreate/waitRecv helpers so the top reads as a four-step narrative at one abstraction level (§1.1). - Regroup Pool fields into config / state / close-coordination layers (§2.5). - Extract discard helper to remove the duplicated close-and-decrement pair in Put. - Drop the "closes excess when idle full" subtest that fabricated an unreachable state via direct live counter mutation (§6.1). - Fold the concurrent goroutines test into TestPool_Run as a subtest so Run has a single owning test function (§6.3).
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #35 +/- ##
==========================================
+ Coverage 53.31% 53.61% +0.29%
==========================================
Files 53 54 +1
Lines 9710 9789 +79
==========================================
+ Hits 5177 5248 +71
- Misses 3919 3924 +5
- Partials 614 617 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Add a six-item checklist to CLAUDE.md covering the coding-patterns rules that have been overlooked on first passes: method order, single abstraction level, struct field layering, one test per public symbol, tests assert behavior, and no duplicated cleanup. Reference it from the Agent Workflow step so other agents pick up the same check.
- Rewrite coding-patterns.md §2.4 as a fixed 10-slot ordering (public type, private type, public/private const, public/private value, public/private function, public/private method) so the sequence of declarations is unambiguous. - Update §2.3 so interface assertions sit in slot 6 (private values) rather than immediately after each type. - Reorder interp/pool.go to match: Pool type, ErrPoolClosed, NewPool, public methods, private methods. - Rename Pool helpers for conciseness: isClosed->dead, tryRecv->take, tryCreate->grow, waitRecv->wait, discard->drop. - Extend CLAUDE.md self-review with the §2.4 ordering and an explicit preference for short intent-revealing helper names.
Interpreter holds per-instance mutable runtime state (frames, stack, heap,
JIT buffer) and is not safe to share across goroutines. Pool lets callers
share an immutable Program while borrowing one Interpreter per goroutine
via Get/Put or Run(ctx, fn). Backed by a bounded channel with explicit
Close() so mmap'd JIT buffers are always released; Reset is called
between borrows to clear runtime state.