Commit e5207f1a by Jan Hubicka Committed by Jan Hubicka

ggc-page.c (release_pages): Output statistics when !quiet_flag.

	* ggc-page.c (release_pages): Output statistics when !quiet_flag.
	(ggc_collect): Dump later to not interfere with release_page dump.
	(ggc_trim): New function.
	* ggc-none.c (ggc_trim): New.
	* ggc.h (ggc_trim): Declare.

	* lto.c (lto_wpa_write_files): Call ggc_trim.

From-SVN: r276878
parent 9d99596e
2019-10-11 Jan Hubicka <hubicka@ucw.cz>
* ggc-page.c (release_pages): Output statistics when !quiet_flag.
(ggc_collect): Dump later to not interfere with release_page dump.
(ggc_trim): New function.
* ggc-none.c (ggc_trim): New.
* ggc.h (ggc_trim): Declare.
2019-10-11 Richard Biener <rguenther@suse.de> 2019-10-11 Richard Biener <rguenther@suse.de>
PR tree-optimization/92066 PR tree-optimization/92066
......
...@@ -72,3 +72,8 @@ void ...@@ -72,3 +72,8 @@ void
ggc_grow (void) ggc_grow (void)
{ {
} }
void
ggc_trim (void)
{
}
...@@ -529,7 +529,6 @@ static void clear_page_group_in_use (page_group *, char *); ...@@ -529,7 +529,6 @@ static void clear_page_group_in_use (page_group *, char *);
#endif #endif
static struct page_entry * alloc_page (unsigned); static struct page_entry * alloc_page (unsigned);
static void free_page (struct page_entry *); static void free_page (struct page_entry *);
static void release_pages (void);
static void clear_marks (void); static void clear_marks (void);
static void sweep_pages (void); static void sweep_pages (void);
static void ggc_recalculate_in_use_p (page_entry *); static void ggc_recalculate_in_use_p (page_entry *);
...@@ -1016,6 +1015,8 @@ free_page (page_entry *entry) ...@@ -1016,6 +1015,8 @@ free_page (page_entry *entry)
static void static void
release_pages (void) release_pages (void)
{ {
size_t n1 = 0;
size_t n2 = 0;
#ifdef USING_MADVISE #ifdef USING_MADVISE
page_entry *p, *start_p; page_entry *p, *start_p;
char *start; char *start;
...@@ -1061,6 +1062,7 @@ release_pages (void) ...@@ -1061,6 +1062,7 @@ release_pages (void)
else else
G.free_pages = p; G.free_pages = p;
G.bytes_mapped -= mapped_len; G.bytes_mapped -= mapped_len;
n1 += len;
continue; continue;
} }
prev = newprev; prev = newprev;
...@@ -1092,6 +1094,7 @@ release_pages (void) ...@@ -1092,6 +1094,7 @@ release_pages (void)
/* Don't count those pages as mapped to not touch the garbage collector /* Don't count those pages as mapped to not touch the garbage collector
unnecessarily. */ unnecessarily. */
G.bytes_mapped -= len; G.bytes_mapped -= len;
n2 += len;
while (start_p != p) while (start_p != p)
{ {
start_p->discarded = true; start_p->discarded = true;
...@@ -1124,6 +1127,7 @@ release_pages (void) ...@@ -1124,6 +1127,7 @@ release_pages (void)
} }
munmap (start, len); munmap (start, len);
n1 += len;
G.bytes_mapped -= len; G.bytes_mapped -= len;
} }
...@@ -1152,10 +1156,20 @@ release_pages (void) ...@@ -1152,10 +1156,20 @@ release_pages (void)
*gp = g->next; *gp = g->next;
G.bytes_mapped -= g->alloc_size; G.bytes_mapped -= g->alloc_size;
free (g->allocation); free (g->allocation);
n1 += g->alloc_size;
} }
else else
gp = &g->next; gp = &g->next;
#endif #endif
if (!quiet_flag && (n1 || n2))
{
fprintf (stderr, " {GC");
if (n1)
fprintf (stderr, " released %luk", (unsigned long)(n1 / 1024));
if (n2)
fprintf (stderr, " madv_dontneed %luk", (unsigned long)(n2 / 1024));
fprintf (stderr, "}");
}
} }
/* This table provides a fast way to determine ceil(log_2(size)) for /* This table provides a fast way to determine ceil(log_2(size)) for
...@@ -2178,19 +2192,22 @@ ggc_collect (void) ...@@ -2178,19 +2192,22 @@ ggc_collect (void)
return; return;
timevar_push (TV_GC); timevar_push (TV_GC);
if (!quiet_flag)
fprintf (stderr, " {GC %luk -> ", (unsigned long) G.allocated / 1024);
if (GGC_DEBUG_LEVEL >= 2) if (GGC_DEBUG_LEVEL >= 2)
fprintf (G.debug_file, "BEGIN COLLECTING\n"); fprintf (G.debug_file, "BEGIN COLLECTING\n");
/* Zero the total allocated bytes. This will be recalculated in the /* Zero the total allocated bytes. This will be recalculated in the
sweep phase. */ sweep phase. */
size_t allocated = G.allocated;
G.allocated = 0; G.allocated = 0;
/* Release the pages we freed the last time we collected, but didn't /* Release the pages we freed the last time we collected, but didn't
reuse in the interim. */ reuse in the interim. */
release_pages (); release_pages ();
/* Output this later so we do not interfere with release_pages. */
if (!quiet_flag)
fprintf (stderr, " {GC %luk -> ", (unsigned long) allocated / 1024);
/* Indicate that we've seen collections at this context depth. */ /* Indicate that we've seen collections at this context depth. */
G.context_depth_collections = ((unsigned long)1 << (G.context_depth + 1)) - 1; G.context_depth_collections = ((unsigned long)1 << (G.context_depth + 1)) - 1;
...@@ -2221,9 +2238,25 @@ ggc_collect (void) ...@@ -2221,9 +2238,25 @@ ggc_collect (void)
fprintf (G.debug_file, "END COLLECTING\n"); fprintf (G.debug_file, "END COLLECTING\n");
} }
/* Assume that all GGC memory is reachable and grow the limits for next collection. /* Return free pages to the system. */
With checking, trigger GGC so -Q compilation outputs how much of memory really is
reachable. */ void
ggc_trim ()
{
timevar_push (TV_GC);
G.allocated = 0;
sweep_pages ();
release_pages ();
if (!quiet_flag)
fprintf (stderr, " {GC trimmed to %luk, %luk mapped}",
(unsigned long) G.allocated / 1024,
(unsigned long) G.bytes_mapped / 1024);
timevar_pop (TV_GC);
}
/* Assume that all GGC memory is reachable and grow the limits for next
collection. With checking, trigger GGC so -Q compilation outputs how much
of memory really is reachable. */
void void
ggc_grow (void) ggc_grow (void)
......
...@@ -243,6 +243,9 @@ extern const char *ggc_alloc_string (const char *contents, int length ...@@ -243,6 +243,9 @@ extern const char *ggc_alloc_string (const char *contents, int length
function is called, not during allocations. */ function is called, not during allocations. */
extern void ggc_collect (void); extern void ggc_collect (void);
/* Return unused memory pages to the system. */
extern void ggc_trim (void);
/* Assume that all GGC memory is reachable and grow the limits for next collection. */ /* Assume that all GGC memory is reachable and grow the limits for next collection. */
extern void ggc_grow (void); extern void ggc_grow (void);
......
2019-10-11 Jan Hubicka <hubicka@ucw.cz> 2019-10-11 Jan Hubicka <hubicka@ucw.cz>
* lto.c (lto_wpa_write_files): Call ggc_trim.
2019-10-11 Jan Hubicka <hubicka@ucw.cz>
* lto.c (lto_wpa_write_files): Prepare all bodies for streaming. * lto.c (lto_wpa_write_files): Prepare all bodies for streaming.
2019-10-10 Richard Biener <rguenther@suse.de> 2019-10-10 Richard Biener <rguenther@suse.de>
......
...@@ -311,6 +311,7 @@ lto_wpa_write_files (void) ...@@ -311,6 +311,7 @@ lto_wpa_write_files (void)
if (gimple_has_body_p (node->decl)) if (gimple_has_body_p (node->decl))
lto_prepare_function_for_streaming (node); lto_prepare_function_for_streaming (node);
ggc_trim ();
/* Generate a prefix for the LTRANS unit files. */ /* Generate a prefix for the LTRANS unit files. */
blen = strlen (ltrans_output_list); blen = strlen (ltrans_output_list);
temp_filename = (char *) xmalloc (blen + sizeof ("2147483648.o")); temp_filename = (char *) xmalloc (blen + sizeof ("2147483648.o"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment