> > On Mon, 23 Nov 2020, Jan Hubicka wrote:
> > 
> > > > On Mon, 23 Nov 2020, Jan Hubicka wrote:
> > > > 
> > > > > Hi,
> > > > > tree-streamer-in currently calls init_tree_ssa that calls 
> > > > > init_ssanames
> > > > > that allocates space in ssa_names array for 50 names.  Later it 
> > > > > streams
> > > > > in the count and calls init_tree_ssa again, this time with correct
> > > > > count, which is rounded up to 50 and allocated again leaking the first
> > > > > array.
> > > > > 
> > > > > This patch fixes it by adding extra argument to init_tree_ssa 
> > > > > specifing
> > > > > whether ssa names should be initialized.  There are few places where 
> > > > > we
> > > > > initialize ssa and only lto streaming is special, so i think extra arg
> > > > > works well here.
> > > > > 
> > > > > I am not quite sure about the 50MB default.  I think it was made 
> > > > > before
> > > > > ggc_free was implemented (so resizing vectors was expensive) and when 
> > > > > we
> > > > > had only one function in SSA form at a time.  Most of functions in C++
> > > > > will probably need fewer than 50 SSA names until inlining.
> > > > > 
> > > > > This saves 21MB of WPA linking libxul.

I actually was overly pesimistic here.  It changes:
GGC memory                                              Leak                   
Garbage            Freed        Overhead            Times
--------------------------------------------------------------------------------------------------------------------------------------------
Total                                                 2116M:100.0%            
779M:100.0%     3744M:100.0%      312M:100.0%       49M
--------------------------------------------------------------------------------------------------------------------------------------------

to

--------------------------------------------------------------------------------------------------------------------------------------------
GGC memory                                              Leak                   
Garbage            Freed        Overhead            Times
--------------------------------------------------------------------------------------------------------------------------------------------
Total                                                 2137M:100.0%            
916M:100.0%     3813M:100.0%      390M:100.0%       49M
--------------------------------------------------------------------------------------------------------------------------------------------

So in addition to 21MB of leak memory (i.e. function bodies still
needed) also 137MB of garbage (i.e. functions eliminated by ICF
or dead code elimination)

Honza

Reply via email to