Hi, we use ggc_grow to prevent garbage collector from triggering at WPA time. After streaming in global trees we know that basically all of them will stay reachable until end of WPA compilation.
This no longer works because tree memory use got down to about 123MB out of 700MB of GGC memory needed for cc1 build. Addition 105MB is used by symbol table and 145 by symbol summaries which is all explicitly ggc_freed. So I am adding ggc_grow after those two stremaing steps. I want to keep all three ggc_grow calls because with checking collection is triggered and we keep testing that stuff if GGC safe and no garbage is produced. We still ggc collect once for cc1 WPA collecing of 118MB of garbage. I think it is mostly produced by ICF but this needs to be double-checked. Bootstrapped/regtested x86_64-linux, comitted. * lto-common.c (read_cgraph_and_symbols): Grow ggc memory use after summary streaming. Index: lto-common.c =================================================================== --- lto-common.c (revision 276935) +++ lto-common.c (working copy) @@ -2781,7 +2781,6 @@ read_cgraph_and_symbols (unsigned nfiles /* At this stage we know that majority of GGC memory is reachable. Growing the limits prevents unnecesary invocation of GGC. */ ggc_grow (); - ggc_collect (); /* Set the hooks so that all of the ipa passes can read in their data. */ lto_set_in_hooks (all_file_decl_data, get_section_data, free_section_data); @@ -2852,7 +2851,11 @@ read_cgraph_and_symbols (unsigned nfiles if (tree_with_vars) ggc_free (tree_with_vars); tree_with_vars = NULL; - ggc_collect (); + /* During WPA we want to prevent ggc collecting by default. Grow limits + until after the IPA summaries are streamed in. Basically all IPA memory + is explcitly managed by ggc_free and ggc collect is not useful. + Exception are the merged declarations. */ + ggc_grow (); timevar_pop (TV_IPA_LTO_DECL_MERGE); /* Each pass will set the appropriate timer. */ @@ -2866,6 +2869,8 @@ read_cgraph_and_symbols (unsigned nfiles else ipa_read_summaries (); + ggc_grow (); + for (i = 0; all_file_decl_data[i]; i++) { gcc_assert (all_file_decl_data[i]->symtab_node_encoder);