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]

Trivial patch to change some memory statistic slots to longs from ints


After several people noted that the ints used to store memory statistics overflowed on several test cases, I threw together this trivial patch to change the slots that stored the statistics from ints to longs. It bootstrapped and passed regtesting, for all languages except ada, with --enable-gather-detailed-mem-stats.

Using it, one finds that 10,292,897,120 bytes of bitmaps and 6,449,831,120 bytes in alloc-pools are allocated with mainline for PR 26854 on x86-64-linux. I don't have checkin privileges.

Brad

	* alloc-pool.c (alloc_pool_descriptor): Make slots longs.
	(output_info): Same.
	(dump_alloc_pool_statistics): Change format to print longs.
	(print_statistics): Same.
	* bitmap.c (bitmap_descriptor): Make slots longs.
	(output_info): Same.
	(print_statistics): Change format to print longs.
	(dump_bitmap_statistics): Same.


=================================================================== RCS file: RCS/alloc-pool.c,v retrieving revision 1.1 diff -u -r1.1 alloc-pool.c --- alloc-pool.c 2008/09/17 18:08:47 1.1 +++ alloc-pool.c 2008/09/17 22:29:36 @@ -68,10 +68,10 @@ struct alloc_pool_descriptor { const char *name; - int allocated; + long allocated; + long peak; + long current; int created; - int peak; - int current; };

 /* Hashtable mapping alloc_pool names to descriptors.  */
@@ -341,8 +341,8 @@
 /* Used to accumulate statistics about alloc_pool sizes.  */
 struct output_info
 {
-  int count;
-  int size;
+  long count;
+  long size;
 };

/* Called via htab_traverse. Output alloc_pool descriptor pointed out by SLOT
@@ -355,7 +355,7 @@


   if (d->allocated)
     {
-      fprintf (stderr, "%-21s %6d %10d %10d %10d\n", d->name,
+      fprintf (stderr, "%-21s %6d %12ld %12ld %12ld\n", d->name,
               d->created, d->allocated, d->peak, d->current);
       i->size += d->allocated;
       i->count += d->created;
@@ -374,14 +374,14 @@
   if (!alloc_pool_hash)
     return;

- fprintf (stderr, "\nAlloc-pool Kind Pools Allocated Peak Leak\n");
- fprintf (stderr, "-------------------------------------------------------------\n");
+ fprintf (stderr, "\nAlloc-pool Kind Pools Allocated Peak Leak\n");
+ fprintf (stderr, "------------------------------------------------------------------- \n");
info.count = 0;
info.size = 0;
htab_traverse (alloc_pool_hash, print_statistics, &info);
- fprintf (stderr, "-------------------------------------------------------------\n");
- fprintf (stderr, "%-20s %7d %10d\n",
+ fprintf (stderr, "------------------------------------------------------------------- \n");
+ fprintf (stderr, "%-20s %9ld %12ld\n",
"Total", info.count, info.size);
- fprintf (stderr, "-------------------------------------------------------------\n");
+ fprintf (stderr, "------------------------------------------------------------------- \n");
#endif
}
===================================================================
RCS file: RCS/bitmap.c,v
retrieving revision 1.1
diff -u -r1.1 bitmap.c
--- bitmap.c 2008/09/17 18:08:47 1.1
+++ bitmap.c 2008/09/17 21:05:09
@@ -36,12 +36,12 @@
{
const char *function;
const char *file;
- int line;
- int allocated;
- int created;
- int peak;
- int current;
+ long allocated;
+ long peak;
+ long current;
int nsearches;
+ int created;
+ int line;
};


 /* Hashtable mapping bitmap names to descriptors.  */
@@ -1960,8 +1960,8 @@
 /* Used to accumulate statistics about bitmap sizes.  */
 struct output_info
 {
-  int count;
-  int size;
+  long count;
+  long size;
 };

/* Called via htab_traverse. Output bitmap descriptor pointed out by SLOT
@@ -1981,7 +1981,7 @@
s1 = s2 + 4;
sprintf (s, "%s:%i (%s)", s1, d->line, d->function);
s[41] = 0;
- fprintf (stderr, "%-41s %6d %10d %10d %10d %10d\n", s,
+ fprintf (stderr, "%-41s %6d %12ld %12ld %12ld %10d\n", s,
d->created, d->allocated, d->peak, d->current, d- >nsearches);
i->size += d->allocated;
i->count += d->created;
@@ -2000,16 +2000,16 @@
return;


fprintf (stderr, "\nBitmap Overall "
- "Allocated Peak Leak searched "
+ " Allocated Peak Leak searched "
" per search\n");
- fprintf (stderr, "----------------------------------------------------------------------- ----------\n");
+ fprintf (stderr, "----------------------------------------------------------------------- ----------------\n");
info.count = 0;
info.size = 0;
htab_traverse (bitmap_desc_hash, print_statistics, &info);
- fprintf (stderr, "----------------------------------------------------------------------- ----------\n");
- fprintf (stderr, "%-40s %7d %10d\n",
+ fprintf (stderr, "----------------------------------------------------------------------- ----------------\n");
+ fprintf (stderr, "%-40s %9ld %12ld\n",
"Total", info.count, info.size);
- fprintf (stderr, "----------------------------------------------------------------------- ----------\n");
+ fprintf (stderr, "----------------------------------------------------------------------- ----------------\n");
#endif
}




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