Stop ug_boring_info retaining a chain of old CoreExpr (and fix a few other retainer leaks)
It was noticed in #20134 that each simplifier iteration used an increasing amount of memory and that a certain portion of memory was not released until the simplfier had completely finished.
I profiled the program using -hi
profiling and observed that there was
a thunk arising in the computation of ug_boring_ok
. On each iteration
ug_boring_ok
would be updated, but not forced, which would leave a
thunk in the shape of
ug_boring_ok = inlineBoringOk expr0 || inlineBoringOk expr2 || inlineBoringOk expr3 || ...
which would retain all previous expr
until ug_boring_ok
was forced
or discarded.
Forcing this accumulator eagerly results in a flat profile over multiple simplifier runs.
This reduces the maximum residency when compiling the test in #20134 from 2GB to 1.3G.
cc @simonpj
Edited by Matthew Pickering