This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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]

gold patch committed: Reserve space in hash table


Paul Pluzhnikov noticed a bunch of hash table resizing which turned out
to be for the hash table which is built during reloc processing to speed
up merge sections.  That is singularly useless resizing, since we know
exactly how many entries we are going to add to the hash table.  I
committed this patch to make the hash table big enough.

Ian


2009-07-09  Ian Lance Taylor  <iant@google.com>

	* merge.cc (Object_merge_map::initialize_input_to_output_map):
	Reserve space in the hash table.


Index: merge.cc
===================================================================
RCS file: /cvs/src/src/gold/merge.cc,v
retrieving revision 1.30
diff -p -u -r1.30 merge.cc
--- merge.cc	23 Mar 2009 21:15:08 -0000	1.30
+++ merge.cc	9 Jul 2009 23:29:18 -0000
@@ -204,6 +204,12 @@ Object_merge_map::initialize_input_to_ou
   Input_merge_map* map = this->get_input_merge_map(shndx);
   gold_assert(map != NULL);
 
+  gold_assert(initialize_map->empty());
+  // We know how many entries we are going to add.
+  // reserve_unordered_map takes an expected count of buckets, not a
+  // count of elements, so double it to try to reduce collisions.
+  reserve_unordered_map(initialize_map, map->entries.size() * 2);
+
   for (Input_merge_map::Entries::const_iterator p = map->entries.begin();
        p != map->entries.end();
        ++p)

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