Hi,

while profiling cc1plus I noticed high hash-table activity for gathering 
statistics, even though I haven't configured with 
--enable-gather-detailed-mem-stats.  Turns out the hash table rewrite 
hard-coded the relevant settings to true.  This patch makes it initialized 
by GATHER_STATISTICS.

Regstrapping on x86_64-linux in progress, I'll commit once that went 
through, as it's IMHO obvious.


Ciao,
Michael.

        * hash-map.h (hash_map::hash_map): Gather statistics only
        when GATHER_STATISTICS is true.
        * hash-set.h (hash_set::hash_set): Ditto.
        * hash-table.h (hash_table::hash_table): Ditto.
        (hash_table::create_ggc): Ditto.

Index: hash-map.h
===================================================================
--- hash-map.h  (revision 231115)
+++ hash-map.h  (working copy)
@@ -107,11 +107,13 @@ class GTY((user)) hash_map
 
 public:
   explicit hash_map (size_t n = 13, bool ggc = false,
-                    bool gather_mem_stats = true CXX_MEM_STAT_INFO)
+                    bool gather_mem_stats = GATHER_STATISTICS
+                    CXX_MEM_STAT_INFO)
     : m_table (n, ggc, gather_mem_stats, HASH_MAP_ORIGIN PASS_MEM_STAT) {}
 
   /* Create a hash_map in ggc memory.  */
-  static hash_map *create_ggc (size_t size, bool gather_mem_stats = true
+  static hash_map *create_ggc (size_t size,
+                              bool gather_mem_stats = GATHER_STATISTICS
                               CXX_MEM_STAT_INFO)
     {
       hash_map *map = ggc_alloc<hash_map> ();
Index: hash-set.h
===================================================================
--- hash-set.h  (revision 231115)
+++ hash-set.h  (working copy)
@@ -27,7 +27,7 @@ class hash_set
 public:
   typedef typename Traits::value_type Key;
   explicit hash_set (size_t n = 13, bool ggc = false CXX_MEM_STAT_INFO)
-    : m_table (n, ggc, true, HASH_SET_ORIGIN PASS_MEM_STAT) {}
+    : m_table (n, ggc, GATHER_STATISTICS, HASH_SET_ORIGIN PASS_MEM_STAT) {}
 
   /* Create a hash_set in gc memory with space for at least n elements.  */
 
Index: hash-table.h
===================================================================
--- hash-table.h        (revision 231115)
+++ hash-table.h        (working copy)
@@ -361,7 +361,8 @@ class hash_table
   typedef typename Descriptor::compare_type compare_type;
 
 public:
-  explicit hash_table (size_t, bool ggc = false, bool gather_mem_stats = true,
+  explicit hash_table (size_t, bool ggc = false,
+                      bool gather_mem_stats = GATHER_STATISTICS,
                       mem_alloc_origin origin = HASH_TABLE_ORIGIN
                       CXX_MEM_STAT_INFO);
   ~hash_table ();
@@ -371,7 +372,8 @@ public:
   create_ggc (size_t n CXX_MEM_STAT_INFO)
   {
     hash_table *table = ggc_alloc<hash_table> ();
-    new (table) hash_table (n, true, true, HASH_TABLE_ORIGIN PASS_MEM_STAT);
+    new (table) hash_table (n, true, GATHER_STATISTICS,
+                           HASH_TABLE_ORIGIN PASS_MEM_STAT);
     return table;
   }
 

Reply via email to