public inbox for gdb-testers@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Create a correctly-sized demangled names hashtable
@ 2019-11-22 18:02 gdb-buildbot
  2019-11-22 18:02 ` Failures on Ubuntu-Aarch64-native-extended-gdbserver-m64, branch master gdb-buildbot
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: gdb-buildbot @ 2019-11-22 18:02 UTC (permalink / raw)
  To: gdb-testers

*** TEST RESULTS FOR COMMIT f8bab2d61d84b4e122ca667c4e458cd2ca29e3b6 ***

commit f8bab2d61d84b4e122ca667c4e458cd2ca29e3b6
Author:     Christian Biesinger <cbiesinger@google.com>
AuthorDate: Mon Nov 18 16:37:31 2019 -0600
Commit:     Christian Biesinger <cbiesinger@google.com>
CommitDate: Fri Nov 22 11:42:41 2019 -0600

    Create a correctly-sized demangled names hashtable
    
    If we have a minsym count, we know the demangled names hashtable will
    be at least that big.  So use that count to size it, so we don't
    have to resize/rehash it as much.
    
    This is a 6% improvement in minsym loading time.
    
    2019-11-22  Christian Biesinger  <cbiesinger@google.com>
    
            * symtab.c (create_demangled_names_hash): Use per_bfd->
            minimal_symbol_count for computing the initial size, if greater
            than our default size.
    
    Change-Id: I1f074d38e1d90af58705ec852f90c84cc034cd2e

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 93258c3d86..838262eba3 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2019-11-22  Christian Biesinger  <cbiesinger@google.com>
+
+	* symtab.c (create_demangled_names_hash): Use per_bfd->
+	minimal_symbol_count for computing the initial size, if greater
+	than our default size.
+
 2019-11-22  Tom de Vries  <tdevries@suse.de>
 
 	* contrib/words.sh: Improve words extraction.
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 0064800313..6affdef58c 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -770,10 +770,20 @@ create_demangled_names_hash (struct objfile_per_bfd_storage *per_bfd)
   /* Choose 256 as the starting size of the hash table, somewhat arbitrarily.
      The hash table code will round this up to the next prime number.
      Choosing a much larger table size wastes memory, and saves only about
-     1% in symbol reading.  */
+     1% in symbol reading.  However, if the minsym count is already
+     initialized (e.g. because symbol name setting was deferred to
+     a background thread) we can initialize the hashtable with a count
+     based on that, because we will almost certainly have at least that
+     many entries.  If we have a nonzero number but less than 256,
+     we still stay with 256 to have some space for psymbols, etc.  */
+
+  /* htab will expand the table when it is 3/4th full, so we account for that
+     here.  +2 to round up.  */
+  int minsym_based_count = (per_bfd->minimal_symbol_count + 2) / 3 * 4;
+  int count = std::max (per_bfd->minimal_symbol_count, minsym_based_count);
 
   per_bfd->demangled_names_hash.reset (htab_create_alloc
-    (256, hash_demangled_name_entry, eq_demangled_name_entry,
+    (count, hash_demangled_name_entry, eq_demangled_name_entry,
      free_demangled_name_entry, xcalloc, xfree));
 }
 


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-11-28  5:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-22 18:02 [binutils-gdb] Create a correctly-sized demangled names hashtable gdb-buildbot
2019-11-22 18:02 ` Failures on Ubuntu-Aarch64-native-extended-gdbserver-m64, branch master gdb-buildbot
2019-11-22 18:14 ` Failures on Ubuntu-Aarch64-m64, " gdb-buildbot
2019-11-28  4:55 ` Failures on Fedora-i686, " gdb-buildbot
2019-11-28  5:15 ` Failures on Fedora-x86_64-cc-with-index, " gdb-buildbot
2019-11-28  5:36 ` Failures on Fedora-x86_64-native-extended-gdbserver-m32, " gdb-buildbot

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).