This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

improve ggc-page.c memory stats


This patch improves a the ggc-page.c memory stats a bit. 
This code is not compiled in by default.


If approved, please check it in, I don't have commit access.



2003-11-06  Dan Nicolaescu  <dann@ics.uci.edu>

	* ggc-page.c (struct globals): Fix comments. Add new member.
	(ggc_alloc): Keep track of the total allocated memory.
	(ggc_print_statistics): Clarify message. Print total allocated
	memory stats.

Index: ggc-page.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ggc-page.c,v
retrieving revision 1.81
diff -c -3 -p -c -r1.81 ggc-page.c
*** ggc-page.c	31 Oct 2003 11:22:32 -0000	1.81
--- ggc-page.c	4 Nov 2003 22:37:39 -0000
*************** static struct globals
*** 401,413 ****
       zero otherwise.  We allocate them all together, to enable a
       better runtime data access pattern.  */
    unsigned long **save_in_use;
- 
  #ifdef GATHER_STATISTICS
    struct
    {
!     /* Total memory allocated with ggc_alloc */
      unsigned long long total_allocated;
!     /* Total overhead for memory to be allocated with ggc_alloc */
      unsigned long long total_overhead;
  
      /* Total allocations and overhead for sizes less than 32, 64 and 128.
--- 401,412 ----
       zero otherwise.  We allocate them all together, to enable a
       better runtime data access pattern.  */
    unsigned long **save_in_use;
  #ifdef GATHER_STATISTICS
    struct
    {
!     /* Total memory allocated with ggc_alloc.  */
      unsigned long long total_allocated;
!     /* Total overhead for memory to be allocated with ggc_alloc.  */
      unsigned long long total_overhead;
  
      /* Total allocations and overhead for sizes less than 32, 64 and 128.
*************** static struct globals
*** 423,428 ****
--- 422,430 ----
      unsigned long long total_allocated_under128;
      unsigned long long total_overhead_under128;
    
+     /* The allocations for each of the allocation orders.  */
+     unsigned long long total_allocated_per_order[NUM_ORDERS];
+ 
      /* The overhead for each of the allocation orders.  */
      unsigned long long total_overhead_per_order[NUM_ORDERS];
    } stats;
*************** ggc_alloc (size_t size)
*** 1171,1178 ****
  #ifdef GATHER_STATISTICS
    {
      G.stats.total_overhead += OBJECT_SIZE (order) - size;
-     G.stats.total_overhead_per_order[order] += OBJECT_SIZE (order) - size;
      G.stats.total_allocated += OBJECT_SIZE(order);
  
      if (size <= 32){
        G.stats.total_overhead_under32 += OBJECT_SIZE (order) - size;
--- 1173,1181 ----
  #ifdef GATHER_STATISTICS
    {
      G.stats.total_overhead += OBJECT_SIZE (order) - size;
      G.stats.total_allocated += OBJECT_SIZE(order);
+     G.stats.total_overhead_per_order[order] += OBJECT_SIZE (order) - size;
+     G.stats.total_allocated_per_order[order] += OBJECT_SIZE (order);
  
      if (size <= 32){
        G.stats.total_overhead_under32 += OBJECT_SIZE (order) - size;
*************** ggc_print_statistics (void)
*** 1830,1835 ****
--- 1833,1840 ----
  
    /* Collect some information about the various sizes of
       allocation.  */
+   fprintf (stderr,
+            "Memory still allocated at the end of the compilation process\n");
    fprintf (stderr, "%-5s %10s  %10s  %10s\n",
  	   "Size", "Allocated", "Used", "Overhead");
    for (i = 0; i < NUM_ORDERS; ++i)
*************** ggc_print_statistics (void)
*** 1871,1876 ****
--- 1876,1883 ----
  
  #ifdef GATHER_STATISTICS  
    {
+     fprintf (stderr, "\nTotal allocations and overheads during the compilation process\n");
+ 
      fprintf (stderr, "Total Overhead:                        %10lld\n",
               G.stats.total_overhead);
      fprintf (stderr, "Total Allocated:                       %10lld\n",
*************** ggc_print_statistics (void)
*** 1890,1898 ****
               G.stats.total_allocated_under128);
     
      for (i = 0; i < NUM_ORDERS; i++)
!       if (G.stats.total_overhead_per_order[i])
!         fprintf (stderr, "Total Overhead  page size %7d:     %10lld\n",
!                  OBJECT_SIZE (i), G.stats.total_overhead_per_order[i]);
    }
  #endif
  }
--- 1897,1909 ----
               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 %7d:     %10lld\n",
!                    OBJECT_SIZE (i), G.stats.total_overhead_per_order[i]);
!           fprintf (stderr, "Total Allocated page size %7d:     %10lld\n",
!                    OBJECT_SIZE (i), G.stats.total_allocated_per_order[i]);
!         }
    }
  #endif
  }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]