public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: mliska <mliska@suse.cz>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH 2/2] Fix memory report layout at various places.
Date: Tue, 02 Jun 2015 11:18:00 -0000	[thread overview]
Message-ID: <d28d15432dc967620da20862be9a6427b3019c36.1433243603.git.mliska@suse.cz> (raw)
In-Reply-To: <bbff984bcfd30921fcd8d87450668d4cd4bad817.1433243603.git.mliska@suse.cz>

gcc/ChangeLog:

2015-06-02  Martin Liska  <mliska@suse.cz>

	* alloc-pool.h (struct pool_usage): Correct space padding.
	* ggc-page.c (ggc_print_statistics): Align columns in a report.
	* mem-stats.h (struct mem_usage): Add argument to print_dash_line.
	* tree.c (dump_tree_statistics): Align columns in a report.
---
 gcc/alloc-pool.h |  2 +-
 gcc/ggc-page.c   | 46 +++++++++++++++++++++++++---------------------
 gcc/mem-stats.h  |  4 ++--
 gcc/tree.c       | 19 ++++++++++++-------
 4 files changed, 40 insertions(+), 31 deletions(-)

diff --git a/gcc/alloc-pool.h b/gcc/alloc-pool.h
index a1727ce..6f1bbed 100644
--- a/gcc/alloc-pool.h
+++ b/gcc/alloc-pool.h
@@ -78,7 +78,7 @@ struct pool_usage: public mem_usage
   inline void dump_footer ()
   {
     print_dash_line ();
-    fprintf (stderr, "%s%75li%10li\n", "Total", (long)m_instances,
+    fprintf (stderr, "%s%82li%10li\n", "Total", (long)m_instances,
 	     (long)m_allocated);
     print_dash_line ();
   }
diff --git a/gcc/ggc-page.c b/gcc/ggc-page.c
index 158156a..7fceeba 100644
--- a/gcc/ggc-page.c
+++ b/gcc/ggc-page.c
@@ -2268,7 +2268,7 @@ ggc_print_statistics (void)
      allocation.  */
   fprintf (stderr,
            "Memory still allocated at the end of the compilation process\n");
-  fprintf (stderr, "%-5s %10s  %10s  %10s\n",
+  fprintf (stderr, "%-8s %10s  %10s  %10s\n",
 	   "Size", "Allocated", "Used", "Overhead");
   for (i = 0; i < NUM_ORDERS; ++i)
     {
@@ -2295,47 +2295,51 @@ ggc_print_statistics (void)
 	  overhead += (sizeof (page_entry) - sizeof (long)
 		       + BITMAP_SIZE (OBJECTS_IN_PAGE (p) + 1));
 	}
-      fprintf (stderr, "%-5lu %10lu%c %10lu%c %10lu%c\n",
+      fprintf (stderr, "%-8lu %10lu%c %10lu%c %10lu%c\n",
 	       (unsigned long) OBJECT_SIZE (i),
 	       SCALE (allocated), STAT_LABEL (allocated),
 	       SCALE (in_use), STAT_LABEL (in_use),
 	       SCALE (overhead), STAT_LABEL (overhead));
       total_overhead += overhead;
     }
-  fprintf (stderr, "%-5s %10lu%c %10lu%c %10lu%c\n", "Total",
+  fprintf (stderr, "%-8s %10lu%c %10lu%c %10lu%c\n", "Total",
 	   SCALE (G.bytes_mapped), STAT_LABEL (G.bytes_mapped),
 	   SCALE (G.allocated), STAT_LABEL (G.allocated),
 	   SCALE (total_overhead), STAT_LABEL (total_overhead));
 
   if (GATHER_STATISTICS)
     {
-      fprintf (stderr, "\nTotal allocations and overheads during the compilation process\n");
+      fprintf (stderr, "\nTotal allocations and overheads during "
+	       "the compilation process\n");
 
-      fprintf (stderr, "Total Overhead:                        %10" HOST_LONG_LONG_FORMAT "d\n",
-	       G.stats.total_overhead);
-      fprintf (stderr, "Total Allocated:                       %10" HOST_LONG_LONG_FORMAT "d\n",
+      fprintf (stderr, "Total Overhead:                          %10"
+	       HOST_LONG_LONG_FORMAT "d\n", G.stats.total_overhead);
+      fprintf (stderr, "Total Allocated:                         %10"
+	       HOST_LONG_LONG_FORMAT "d\n",
 	       G.stats.total_allocated);
 
-      fprintf (stderr, "Total Overhead  under  32B:            %10" HOST_LONG_LONG_FORMAT "d\n",
-	       G.stats.total_overhead_under32);
-      fprintf (stderr, "Total Allocated under  32B:            %10" HOST_LONG_LONG_FORMAT "d\n",
-	       G.stats.total_allocated_under32);
-      fprintf (stderr, "Total Overhead  under  64B:            %10" HOST_LONG_LONG_FORMAT "d\n",
-	       G.stats.total_overhead_under64);
-      fprintf (stderr, "Total Allocated under  64B:            %10" HOST_LONG_LONG_FORMAT "d\n",
-	       G.stats.total_allocated_under64);
-      fprintf (stderr, "Total Overhead  under 128B:            %10" HOST_LONG_LONG_FORMAT "d\n",
-	       G.stats.total_overhead_under128);
-      fprintf (stderr, "Total Allocated under 128B:            %10" HOST_LONG_LONG_FORMAT "d\n",
-	       G.stats.total_allocated_under128);
+      fprintf (stderr, "Total Overhead  under  32B:              %10"
+	       HOST_LONG_LONG_FORMAT "d\n", G.stats.total_overhead_under32);
+      fprintf (stderr, "Total Allocated under  32B:              %10"
+	       HOST_LONG_LONG_FORMAT "d\n", G.stats.total_allocated_under32);
+      fprintf (stderr, "Total Overhead  under  64B:              %10"
+	       HOST_LONG_LONG_FORMAT "d\n", G.stats.total_overhead_under64);
+      fprintf (stderr, "Total Allocated under  64B:              %10"
+	       HOST_LONG_LONG_FORMAT "d\n", G.stats.total_allocated_under64);
+      fprintf (stderr, "Total Overhead  under 128B:              %10"
+	       HOST_LONG_LONG_FORMAT "d\n", G.stats.total_overhead_under128);
+      fprintf (stderr, "Total Allocated under 128B:              %10"
+	       HOST_LONG_LONG_FORMAT "d\n", G.stats.total_allocated_under128);
 
       for (i = 0; i < NUM_ORDERS; i++)
 	if (G.stats.total_allocated_per_order[i])
 	  {
-	    fprintf (stderr, "Total Overhead  page size %7lu:     %10" HOST_LONG_LONG_FORMAT "d\n",
+	    fprintf (stderr, "Total Overhead  page size %9lu:     %10"
+		     HOST_LONG_LONG_FORMAT "d\n",
 		     (unsigned long) OBJECT_SIZE (i),
 		     G.stats.total_overhead_per_order[i]);
-	    fprintf (stderr, "Total Allocated page size %7lu:     %10" HOST_LONG_LONG_FORMAT "d\n",
+	    fprintf (stderr, "Total Allocated page size %9lu:     %10"
+		     HOST_LONG_LONG_FORMAT "d\n",
 		     (unsigned long) OBJECT_SIZE (i),
 		     G.stats.total_allocated_per_order[i]);
 	  }
diff --git a/gcc/mem-stats.h b/gcc/mem-stats.h
index fea68fa..9914425 100644
--- a/gcc/mem-stats.h
+++ b/gcc/mem-stats.h
@@ -168,9 +168,9 @@ struct mem_usage
   }
 
   /* Print line made of dashes.  */
-  static inline void print_dash_line ()
+  static inline void print_dash_line (size_t count = 140)
   {
-    fprintf (stderr, "%s\n", std::string (140, '-').c_str ());
+    fprintf (stderr, "%s\n", std::string (count, '-').c_str ());
   }
 
   /* Dump header with NAME.  */
diff --git a/gcc/tree.c b/gcc/tree.c
index ca48c60..441ab3a 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -9125,6 +9125,8 @@ get_callee_fndecl (const_tree call)
   return NULL_TREE;
 }
 
+#define TREE_MEM_USAGE_SPACES 40
+
 /* Print debugging information about tree nodes generated during the compile,
    and any language-specific information.  */
 
@@ -9135,8 +9137,8 @@ dump_tree_statistics (void)
     {
       int i;
       int total_nodes, total_bytes;
-      fprintf (stderr, "Kind                   Nodes      Bytes\n");
-      fprintf (stderr, "---------------------------------------\n");
+      fprintf (stderr, "\nKind                   Nodes      Bytes\n");
+      mem_usage::print_dash_line (TREE_MEM_USAGE_SPACES);
       total_nodes = total_bytes = 0;
       for (i = 0; i < (int) all_kinds; i++)
 	{
@@ -9145,17 +9147,20 @@ dump_tree_statistics (void)
 	  total_nodes += tree_node_counts[i];
 	  total_bytes += tree_node_sizes[i];
 	}
-      fprintf (stderr, "---------------------------------------\n");
+      mem_usage::print_dash_line (TREE_MEM_USAGE_SPACES);
       fprintf (stderr, "%-20s %7d %10d\n", "Total", total_nodes, total_bytes);
-      fprintf (stderr, "---------------------------------------\n");
+      mem_usage::print_dash_line (TREE_MEM_USAGE_SPACES);
       fprintf (stderr, "Code                   Nodes\n");
-      fprintf (stderr, "----------------------------\n");
+      mem_usage::print_dash_line (TREE_MEM_USAGE_SPACES);
       for (i = 0; i < (int) MAX_TREE_CODES; i++)
-	fprintf (stderr, "%-20s %7d\n", get_tree_code_name ((enum tree_code) i),
+	fprintf (stderr, "%-32s %7d\n", get_tree_code_name ((enum tree_code) i),
                  tree_code_counts[i]);
-      fprintf (stderr, "----------------------------\n");
+      mem_usage::print_dash_line (TREE_MEM_USAGE_SPACES);
+      fprintf (stderr, "\n");
       ssanames_print_statistics ();
+      fprintf (stderr, "\n");
       phinodes_print_statistics ();
+      fprintf (stderr, "\n");
     }
   else
     fprintf (stderr, "(No per-node statistics)\n");
-- 
2.1.4

  reply	other threads:[~2015-06-02 11:14 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-02 11:14 [PATCH 1/2] Memory statistics enhancement mliska
2015-06-02 11:18 ` mliska [this message]
2015-06-02 14:11   ` [PATCH 2/2] Fix memory report layout at various places Jeff Law
2015-06-02 14:00 ` [PATCH 1/2] Memory statistics enhancement Jeff Law
2015-06-02 15:38   ` Martin Liška
2015-06-02 17:33     ` Jeff Law
2015-06-03  9:16       ` Martin Liška
2015-06-03 13:19         ` Jeff Law
2015-06-03 14:27           ` Martin Liška
2015-06-03 17:32             ` Jeff Law
2015-06-03  9:47 ` Martin Liška
2015-06-03 13:27   ` Jeff Law
2015-06-08 15:02 ` Martin Liška
2015-06-16 13:18   ` Martin Liška

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d28d15432dc967620da20862be9a6427b3019c36.1433243603.git.mliska@suse.cz \
    --to=mliska@suse.cz \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).