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
end def infer_all_returns # The return-type fixpoint allocates heavily (per-pass type-string # rebuilds); without a collection here the transient garbage from each # of the ~15 passes accumulates between the GC's (growing) auto-collect # points, so peak RSS tracks the high-water of churn rather than the # live set. Collecting at the pass boundary caps that: on a large # auto-generated class graph it roughly halves analyzer peak RSS # (#1302) at a few % wall cost, and is result-neutral (only unreachable # garbage is freed). GC.start # Pre-pass: infer class method param types from body usage infer_cls_meth_param_from_body # Pre-pass: scan for .new calls to infer constructor param types