This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Add obstack for canonical file name hash table


On Tue, 5 Nov 2019, Jan Hubicka wrote:

> > On Tue, 5 Nov 2019, Jan Hubicka wrote:
> > 
> > > Hi,
> > > looking into malloc overhead I noticed that we do a lot of small
> > > allocations to hold file names comming from location info. This patch
> > > puts it into an obstack so it interleaves memory allocated by scc_hash
> > > less frequently.
> > > (Still we end up interleaving 64k pages which are permanent - in fact
> > > this table seems to leak from WPA and temporary during stream in)
> > > 
> > > Bootstrapped/regtested x86_64-linux. OK?
> > 
> > I think the obstack deserves a big fat comment that it cannot be
> > reclaimed since the linemap retains permanent pointers into it.
> > That also suggests to put the string_slot into a separate obstack
> 
> The hasher is sort of ethernal, too, since at any time we want to be
> able to load more from input streams, so we can not really free it.
> Well, I guess just prior streaming we can, so I will split it.
> > or better, make the hasher (and other string_slot hashers)
> > embed the string_slot struct in the hash?  We'd save an allocation
> > everywhere.
> 
> Well, if we want to free hasher, then we want to keep string separate +
> comment on obstack, right?  I sill update patch tonight.

Yes, we want to have an obstack with just the strings and a comment
that we have to keep that.

Richard.

> Honza
> > 
> > Richard.
> > 
> > > Honza
> > > 
> > > 	* lto-streamer-in.c (file_name_obstack): New obstack.
> > > 	(canon_file_name): Use it.
> > > 	(lto_reader_init): Initialize it.
> > > Index: lto-streamer-in.c
> > > ===================================================================
> > > --- lto-streamer-in.c	(revision 277796)
> > > +++ lto-streamer-in.c	(working copy)
> > > @@ -57,6 +57,7 @@ freeing_string_slot_hasher::remove (valu
> > >  
> > >  /* The table to hold the file names.  */
> > >  static hash_table<freeing_string_slot_hasher> *file_name_hash_table;
> > > +static struct obstack file_name_obstack;
> > >  
> > >  
> > >  /* Check that tag ACTUAL has one of the given values.  NUM_TAGS is the
> > > @@ -113,8 +114,9 @@ canon_file_name (const char *string)
> > >        char *saved_string;
> > >        struct string_slot *new_slot;
> > >  
> > > -      saved_string = (char *) xmalloc (len + 1);
> > > -      new_slot = XCNEW (struct string_slot);
> > > +      saved_string = XOBNEWVEC (&file_name_obstack, char, len + 1);
> > > +      new_slot = XOBNEWVAR (&file_name_obstack,
> > > +			    struct string_slot, sizeof (struct string_slot));
> > >        memcpy (saved_string, string, len + 1);
> > >        new_slot->s = saved_string;
> > >        new_slot->len = len;
> > > @@ -1723,6 +1725,7 @@ lto_reader_init (void)
> > >    lto_streamer_init ();
> > >    file_name_hash_table
> > >      = new hash_table<freeing_string_slot_hasher> (37);
> > > +  gcc_obstack_init (&file_name_obstack);
> > >  }
> > >  
> > >  
> > > 
> > 
> > -- 
> > Richard Biener <rguenther@suse.de>
> > SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg,
> > Germany; GF: Felix Imendörffer; HRB 36809 (AG Nuernberg)
> 
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg,
Germany; GF: Felix Imendörffer; HRB 36809 (AG Nuernberg)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]