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 or better, make the hasher (and other string_slot hashers) embed the string_slot struct in the hash? We'd save an allocation everywhere. 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 <rguent...@suse.de> SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany; GF: Felix Imendörffer; HRB 36809 (AG Nuernberg)