]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Precompute hash value for symbol_set_names users/cbiesinger/parallel-minsyms-mutex
authorChristian Biesinger <cbiesinger@google.com>
Thu, 3 Oct 2019 18:05:06 +0000 (13:05 -0500)
committerChristian Biesinger <cbiesinger@google.com>
Thu, 3 Oct 2019 18:17:12 +0000 (13:17 -0500)
We can also compute the hash for the mangled name on a background
thread so make this function even faster (about a 7% speedup).

gdb/ChangeLog:

2019-10-03  Christian Biesinger  <cbiesinger@google.com>

* minsyms.c (minimal_symbol_reader::install): Also compute the hash
of the mangled name on the background thread.
* symtab.c (symbol_set_names): Allow passing in the hash of the
linkage_name.
* symtab.h (symbol_set_names): Likewise.

gdb/minsyms.c
gdb/symtab.c
gdb/symtab.h

index 95ca9f6c930d3170353ed61d838c4144447c9608..b60381a0c91bacf1fd2f2b5ae65134be6953f46e 100644 (file)
@@ -1342,6 +1342,11 @@ minimal_symbol_reader::install ()
       std::mutex demangled_mutex;
 #endif
 
+      struct computed_hash_values {
+       hashval_t mangled_name_hash;
+      };
+      std::vector<computed_hash_values> hash_values (mcount);
+
       msymbols = m_objfile->per_bfd->msymbols.get ();
       gdb::parallel_for_each
        (&msymbols[0], &msymbols[mcount],
@@ -1361,6 +1366,9 @@ minimal_symbol_reader::install ()
                   symbol_set_demangled_name (msym, demangled_name,
                                              &m_objfile->per_bfd->storage_obstack);
                   msym->name_set = 1;
+
+                  size_t idx = msym - msymbols;
+                  hash_values[idx].mangled_name_hash = htab_hash_string (msym->name);
                 }
             }
           {
@@ -1371,9 +1379,11 @@ minimal_symbol_reader::install ()
 #endif
             for (minimal_symbol *msym = start; msym < end; ++msym)
               {
+                size_t idx = msym - msymbols;
                 symbol_set_names (msym, msym->name,
                                   strlen (msym->name), 0,
-                                  m_objfile->per_bfd);
+                                  m_objfile->per_bfd,
+                                  hash_values[idx].mangled_name_hash);
               }
           }
         });
index 47da5cf4e8cb01c275219e920d915fbf059c2c3e..40cc34b2059c06f829add9069dec5fd122b98d95 100644 (file)
@@ -808,7 +808,7 @@ symbol_find_demangled_name (struct general_symbol_info *gsymbol,
 void
 symbol_set_names (struct general_symbol_info *gsymbol,
                  const char *linkage_name, int len, bool copy_name,
-                 struct objfile_per_bfd_storage *per_bfd)
+                 struct objfile_per_bfd_storage *per_bfd, hashval_t hash)
 {
   struct demangled_name_entry **slot;
   /* A 0-terminated copy of the linkage name.  */
@@ -854,9 +854,11 @@ symbol_set_names (struct general_symbol_info *gsymbol,
     create_demangled_names_hash (per_bfd);
 
   entry.mangled = linkage_name_copy;
+  if (hash == 0)
+    hash = hash_demangled_name_entry (&entry);
   slot = ((struct demangled_name_entry **)
-          htab_find_slot (per_bfd->demangled_names_hash.get (),
-                   &entry, INSERT));
+          htab_find_slot_with_hash (per_bfd->demangled_names_hash.get (),
+                                   &entry, hash, INSERT));
 
   /* If this name is not in the hash table, add it.  */
   if (*slot == NULL
index 17903df92d69447002407969780fe7565a91b306..2814f401fe820ade89166eb7cf6cc077a3303ef0 100644 (file)
@@ -502,13 +502,16 @@ extern char *symbol_find_demangled_name (struct general_symbol_info *gsymbol,
   (symbol)->ginfo.name = (linkage_name)
 
 /* Set the linkage and natural names of a symbol, by demangling
-   the linkage name.  */
+   the linkage name.  Optionally, HASH can be set to the value
+   of htab_hash_string (linkage_name) (if nullterminated), to
+   speed up this function.  */
 #define SYMBOL_SET_NAMES(symbol,linkage_name,len,copy_name,objfile)    \
   symbol_set_names (&(symbol)->ginfo, linkage_name, len, copy_name, \
                    (objfile)->per_bfd)
 extern void symbol_set_names (struct general_symbol_info *symbol,
                              const char *linkage_name, int len, bool copy_name,
-                             struct objfile_per_bfd_storage *per_bfd);
+                             struct objfile_per_bfd_storage *per_bfd,
+                             hashval_t hash = 0);
 
 /* Now come lots of name accessor macros.  Short version as to when to
    use which: Use SYMBOL_NATURAL_NAME to refer to the name of the