Skip to content

Stop ug_boring_info retaining a chain of old CoreExpr (and fix a few other retainer leaks)

Matthew Pickering requested to merge wip/t20134 into master

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.

Before: 2021-07-21-093445_1151x988

After: 2021-07-21-093451_1214x1000

cc @simonpj

Edited by Matthew Pickering

Merge request reports