diff options
author | Zack Weinberg <zack@wolery.cumb.org> | 2000-08-29 20:57:11 +0000 |
---|---|---|
committer | Zack Weinberg <zack@gcc.gnu.org> | 2000-08-29 20:57:11 +0000 |
commit | fba0bfd4546bb2b864a841cf1d43957dbaa38a89 (patch) | |
tree | 467a74cb03ab3a07329d87c25f28745ba9ed5e7f /gcc/ggc-page.c | |
parent | 612105a61a150594ef233db883b1bf1ad6501720 (diff) | |
download | gcc-fba0bfd4546bb2b864a841cf1d43957dbaa38a89.tar.gz |
flags.h (time_report, mem_report): New global flags.
* flags.h (time_report, mem_report): New global flags.
* toplev.c: Define time_report and mem_report.
(f_options): Add -ftime-report and -fmem-report.
(compile_file): Turn on time_report if quiet_flag is off.
Call ggc_print_statistics at very end if mem_report is on.
* timevar.c (TIMEVAR_ENABLE): Examine time_report, not quiet_flag.
* ggc-common.c (ggc_print_statistics): Rename to
ggc_print_common_statistics; all callers changed. Scale
quantities above 10K to kilobytes and above 10M to megabytes.
* ggc-page.c (ggc_page_print_statistics): Rename to
ggc_print_statistics. Report memory consumed by internal data
structures for each allocation bucket. Scale quantities above
10K to kilobytes and above 10M to megabytes.
* ggc-simple.c: Prototype debug_ggc_tree to avoid warning.
Cast PTR_KEY(p) to unsigned long in fprintf call to avoid warning.
Define tally_leaves always.
(ggc_print_statistics): New function.
* ggc.h: Adjust for renamed functions.
From-SVN: r36049
Diffstat (limited to 'gcc/ggc-page.c')
-rw-r--r-- | gcc/ggc-page.c | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/gcc/ggc-page.c b/gcc/ggc-page.c index b395aaaf92e..8744129aaaf 100644 --- a/gcc/ggc-page.c +++ b/gcc/ggc-page.c @@ -1162,12 +1162,19 @@ ggc_collect () } /* Print allocation statistics. */ +#define SCALE(x) ((unsigned long) ((x) < 1024*10 \ + ? (x) \ + : ((x) < 1024*1024*10 \ + ? (x) / 1024 \ + : (x) / (1024*1024)))) +#define LABEL(x) ((x) < 1024*10 ? ' ' : ((x) < 1024*1024*10 ? 'k' : 'M')) void -ggc_page_print_statistics () +ggc_print_statistics () { struct ggc_statistics stats; unsigned int i; + size_t total_overhead = 0; /* Clear the statistics. */ memset (&stats, 0, sizeof (stats)); @@ -1176,7 +1183,7 @@ ggc_page_print_statistics () G.allocated_last_gc = 0; /* Collect and print the statistics common across collectors. */ - ggc_print_statistics (stderr, &stats); + ggc_print_common_statistics (stderr, &stats); /* Release free pages so that we will not count the bytes allocated there as part of the total allocated memory. */ @@ -1184,34 +1191,41 @@ ggc_page_print_statistics () /* Collect some information about the various sizes of allocation. */ - fprintf (stderr, "\n%-4s%-16s%-16s\n", "Log", "Allocated", "Used"); + fprintf (stderr, "\n%-5s %10s %10s %10s\n", + "Log", "Allocated", "Used", "Overhead"); for (i = 0; i < HOST_BITS_PER_PTR; ++i) { page_entry *p; size_t allocated; size_t in_use; + size_t overhead; /* Skip empty entries. */ if (!G.pages[i]) continue; - allocated = in_use = 0; + overhead = allocated = in_use = 0; /* Figure out the total number of bytes allocated for objects of - this size, and how many of them are actually in use. */ + this size, and how many of them are actually in use. Also figure + out how much memory the page table is using. */ for (p = G.pages[i]; p; p = p->next) { allocated += p->bytes; in_use += (OBJECTS_PER_PAGE (i) - p->num_free_objects) * (1 << i); + + overhead += (sizeof (page_entry) - sizeof (long) + + BITMAP_SIZE (OBJECTS_PER_PAGE (i) + 1)); } - fprintf (stderr, "%-3d %-15lu %-15lu\n", i, - (unsigned long) allocated, (unsigned long) in_use); + fprintf (stderr, "%-5d %10ld%c %10ld%c %10ld%c\n", i, + SCALE (allocated), LABEL (allocated), + SCALE (in_use), LABEL (in_use), + SCALE (overhead), LABEL (overhead)); + total_overhead += overhead; } - - /* Print out some global information. */ - fprintf (stderr, "\nTotal bytes marked: %lu\n", - (unsigned long) G.allocated); - fprintf (stderr, "Total bytes mapped: %lu\n", - (unsigned long) G.bytes_mapped); + fprintf (stderr, "%-5s %10ld%c %10ld%c %10ld%c\n", "Total", + SCALE (G.bytes_mapped), LABEL (G.bytes_mapped), + SCALE (G.allocated), LABEL(G.allocated), + SCALE (total_overhead), LABEL (total_overhead)); } |