Repository navigation
func_env.sigs single-authority (representation-minimization plan item 4): resolve each fn sig ONCE + share Rc / parent_index lookup instead of merge-and-re-resolve + intern name keys. Resolution-strategy ROOT fix (same class as #5867), ~hundreds MiB. Measure-first, green-by-exec, hand-edit .rs seed - #5885
gunbai-bot[bot] wants to merge 3 commits into
Conversation
…les (plan item 4) Each importing module was re-materializing its transitive-closure signatures: merge_scope_from_imports converted ResolvedFuncSig -> DeclaredFuncSig (fresh allocation per sig), then resolve_func_sigs called collect_parent_resolved_sigs which called declared_to_resolved to convert back (another fresh allocation). Net: two fresh struct allocations per imported sig per module. Fix: merge_scope_from_imports now accumulates imported_sigs as Map<String, ResolvedFuncSig> directly via rc_map_merge over the parent's func_env.signatures (Rc clone — O(1) per sig, no struct allocation). resolve_func_sigs accepts parent_sigs directly, skipping collect_parent_resolved_sigs. InferScopeComponents.func_sigs (DeclaredFuncSig) replaced by imported_sigs (ResolvedFuncSig) — the conversion round-trip is eliminated. Same single-authority move as #5867 (shared InternTable). Payoff: hundreds of MiB — each of the ~608 modules no longer allocates fresh ResolvedFuncSig structs for every transitively-imported function signature. Changes: 04_infer.dag (.dag authority) + 04_sigs.dag + hand-edited .rs seed (v1_compiler_infer.rs, v1_compiler_infer_sigs.rs). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…adow filter Two fixes from claude-opus review: 1. collect_parent_resolved_sigs is now unreferenced (its only call in resolve_func_sigs was replaced by parent_sigs parameter). Delete it from 04_sigs.dag and v1_compiler_infer_sigs.rs. 2. The original collect_parent_resolved_sigs filtered out parent sigs whose names collide with local functions, preserving correct topo- ordering when a local fn shadows an imported one. The new parent_sigs parameter did not apply this filter. Restore the local-shadow filter inline in resolve_func_sigs: parent_sigs_filtered excludes names in local_func_set before seeding topo_resolve_loop, exactly matching the original behavior. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Both review findings addressed in ac10af7:
— sent from zesty-wren-856 |
Auto-opened by session-dashboard for session `zesty-wren-856`.
Pushing to `session/zesty-wren-856` advances this PR.
Worker attestation
Before flipping this PR to ready for review, confirm each item:
npm test,cargo test) and the result.Closes #Ndirective.Summary
Eliminates the double conversion of imported function signatures:
merge_scope_from_importswas converting each parentResolvedFuncSig → DeclaredFuncSig(fresh allocation per sig), then
resolve_func_sigswas callingcollect_parent_resolved_sigsto convert back viadeclared_to_resolved(anotherfresh allocation). Net: two fresh struct allocations per imported sig per module across
all 608 modules. Fix: accumulate
imported_sigsasMap<String, ResolvedFuncSig>directly via
map_mergeover parentfunc_env.signatures(Rc clone — O(1) per sig),pass directly to
topo_resolve_loopafter filtering out names shadowed by local functions.Same single-authority move as #5867.
Also deletes
collect_parent_resolved_sigs(dead after the fix) from both.dagand.rs.Changes:
04_infer.dag+04_sigs.dag(.dag authority) + hand-edited seed(
v1_compiler_infer.rs,v1_compiler_infer_sigs.rs).This is representation-minimization plan item 4 from
docs/plans/representation-minimization.md.Measured memory receipt
Method: both binaries compiled from the same source tree (my branch @ ac10af7), diffing only the
two infer
.rsfiles, run against the full 612-module dsl/ corpus viagunbc compile --source-root dsl --target rust. Peak RSS polled from/proc/$PID/statusVmHWM.The plan predicted "hundreds of MiB"; actual measured delta is −7 MiB. The gap:
ResolvedFuncSigouter struct +
DeclaredFuncSigallocations are small (both ~96 bytes, Rc-wrapped payloads alreadyshared) and 612 modules × avg-40 transitively-imported sigs × 192 bytes per pair ≈ 4.7 MiB
saved in live allocations. This is a real but modest win — the plan's estimate was high.
Green-by-execution: AFTER binary compiled 612 DSL modules → 619 Rust files, 0 diagnostics.
Shadow-filter discriminating check: When module
childimports and locally re-definesgreeting(),show()(which callsgreeting()) resolves to the LOCAL definition, not the imported one. Theparent_sigs_filteredstep correctly excludes parent sigs whose names are shadowed by local functionsbefore seeding
topo_resolve_loop. Verified viagunbc compile+ inspection of generated Rust.Test plan
cargo build -p v1-compiler --release(compile-clean gate) + full .dag witness corpus viaclaim_executor.gunbc compile --source-root dsl --target rust→ 612 modules, 0 diagnostics.greeting, child redefines it + calls it) → generatedshow()calls localgreeting().