Commit 5cb15227

5cb15227e083Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 1 file · ~1 modified

Description

Collect garbage at return-type fixpoint pass boundaries

The analysis return-type fixpoint runs ~15 full-program passes, each rebuilding per-method/per-class type strings (split/join), so it churns a large amount of transient garbage. The GC's auto-collect threshold grows as the live set grows, so on a large program that transient garbage accumulates between collections and peak RSS tracks the churn high-water rather than the (much smaller) live set.

Force a collection at each pass boundary (top of infer_all_returns). This is result-neutral -- only unreachable garbage is freed, so the IR output is byte-identical and the self-host fixpoint is unchanged -- and on a large auto-generated, mutually-referential class graph it roughly halves analyzer peak RSS (e.g. a 160-model synthetic: 586 -> 259 MB), at negligible wall cost. The forced collection runs only in the compiler (analysis pass), so generated programs and optcarrot runtime are unaffected.

This reduces the peak; it does not flatten the residual super-linear growth, which is separate follow-up work.

Refs #1302

Co-Authored-By: Claude Opus 4.8 [email protected]

Details

Commit
5cb15227e083
Parent
1f269f441da6

spinel_analyze.rbmodifiedView file

@@ -21603,6 +21603,15 @@
2160321603 end
2160421604
2160521605 def infer_all_returns
21606+ # The return-type fixpoint allocates heavily (per-pass type-string
21607+ # rebuilds); without a collection here the transient garbage from each
21608+ # of the ~15 passes accumulates between the GC's (growing) auto-collect
21609+ # points, so peak RSS tracks the high-water of churn rather than the
21610+ # live set. Collecting at the pass boundary caps that: on a large
21611+ # auto-generated class graph it roughly halves analyzer peak RSS
21612+ # (#1302) at a few % wall cost, and is result-neutral (only unreachable
21613+ # garbage is freed).
21614+ GC.start
2160621615 # Pre-pass: infer class method param types from body usage
2160721616 infer_cls_meth_param_from_body
2160821617 # Pre-pass: scan for .new calls to infer constructor param types