This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[review v3] Compute msymbol hash codes in parallel
- From: "Christian Biesinger (Code Review)" <gerrit at gnutoolchain-gerrit dot osci dot io>
- To: Christian Biesinger <cbiesinger at google dot com>, Tom Tromey <tromey at sourceware dot org>, gdb-patches at sourceware dot org
- Date: Tue, 29 Oct 2019 17:56:24 -0400
- Subject: [review v3] Compute msymbol hash codes in parallel
- Auto-submitted: auto-generated
- References: <gerrit.1572031795000.Ifaa3346e9998f05743bff9e2eaad3f83b954d071@gnutoolchain-gerrit.osci.io>
- Reply-to: cbiesinger at google dot com, tromey at sourceware dot org, cbiesinger at google dot com, gdb-patches at sourceware dot org
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/308
......................................................................
Compute msymbol hash codes in parallel
This is for the msymbol_hash and msymbol_demangled_hash hashtables
in objfile_per_bfd_storage. This basically computes those hash
codes together with the demangled symbol name in the background,
before it inserts the symbols in the hash table.
gdb/ChangeLog:
2019-09-30 Christian Biesinger <cbiesinger@google.com>
* minsyms.c (add_minsym_to_hash_table): Use a previously computed
hash code if possible.
(add_minsym_to_demangled_hash_table): Likewise.
(minimal_symbol_reader::install): Compute the hash codes for msymbol
on the background thread.
* symtab.h (struct minimal_symbol) <hash_value, demangled_hash_value>:
Add these fields.
Change-Id: Ifaa3346e9998f05743bff9e2eaad3f83b954d071
---
M gdb/minsyms.c
1 file changed, 25 insertions(+), 15 deletions(-)
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index c53094b..0244171 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -141,12 +141,12 @@
/* Add the minimal symbol SYM to an objfile's minsym hash table, TABLE. */
static void
add_minsym_to_hash_table (struct minimal_symbol *sym,
- struct minimal_symbol **table)
+ struct minimal_symbol **table,
+ unsigned int hash_value)
{
if (sym->hash_next == NULL)
{
- unsigned int hash
- = msymbol_hash (MSYMBOL_LINKAGE_NAME (sym)) % MINIMAL_SYMBOL_HASH_SIZE;
+ unsigned int hash = hash_value % MINIMAL_SYMBOL_HASH_SIZE;
sym->hash_next = table[hash];
table[hash] = sym;
@@ -157,18 +157,16 @@
TABLE. */
static void
add_minsym_to_demangled_hash_table (struct minimal_symbol *sym,
- struct objfile *objfile)
+ struct objfile *objfile,
+ unsigned int hash_value)
{
if (sym->demangled_hash_next == NULL)
{
- unsigned int hash = search_name_hash (MSYMBOL_LANGUAGE (sym),
- MSYMBOL_SEARCH_NAME (sym));
-
objfile->per_bfd->demangled_hash_languages.set (MSYMBOL_LANGUAGE (sym));
struct minimal_symbol **table
= objfile->per_bfd->msymbol_demangled_hash;
- unsigned int hash_index = hash % MINIMAL_SYMBOL_HASH_SIZE;
+ unsigned int hash_index = hash_value % MINIMAL_SYMBOL_HASH_SIZE;
sym->demangled_hash_next = table[hash_index];
table[hash_index] = sym;
}
@@ -1253,6 +1251,8 @@
{
size_t name_length;
hashval_t mangled_name_hash;
+ unsigned int minsym_hash;
+ unsigned int minsym_demangled_hash;
};
/* Build (or rebuild) the minimal symbol hash tables. This is necessary
@@ -1260,7 +1260,9 @@
thus causing the internal minimal_symbol pointers to become jumbled. */
static void
-build_minimal_symbol_hash_tables (struct objfile *objfile)
+build_minimal_symbol_hash_tables
+ (struct objfile *objfile,
+ const std::vector<computed_hash_values>& hash_values)
{
int i;
struct minimal_symbol *msym;
@@ -1273,17 +1275,20 @@
}
/* Now, (re)insert the actual entries. */
- for ((i = objfile->per_bfd->minimal_symbol_count,
+ int mcount = objfile->per_bfd->minimal_symbol_count;
+ for ((i = 0,
msym = objfile->per_bfd->msymbols.get ());
- i > 0;
- i--, msym++)
+ i < mcount;
+ i++, msym++)
{
msym->hash_next = 0;
- add_minsym_to_hash_table (msym, objfile->per_bfd->msymbol_hash);
+ add_minsym_to_hash_table (msym, objfile->per_bfd->msymbol_hash,
+ hash_values[i].minsym_hash);
msym->demangled_hash_next = 0;
if (MSYMBOL_SEARCH_NAME (msym) != MSYMBOL_LINKAGE_NAME (msym))
- add_minsym_to_demangled_hash_table (msym, objfile);
+ add_minsym_to_demangled_hash_table
+ (msym, objfile, hash_values[i].minsym_demangled_hash);
}
}
@@ -1395,6 +1400,11 @@
hash_values[idx].mangled_name_hash
= fast_hash (msym->name, hash_values[idx].name_length);
}
+ hash_values[idx].minsym_hash
+ = msymbol_hash (MSYMBOL_LINKAGE_NAME (msym));
+ hash_values[idx].minsym_demangled_hash
+ = search_name_hash (MSYMBOL_LANGUAGE (msym),
+ MSYMBOL_SEARCH_NAME (msym));
}
{
/* To limit how long we hold the lock, we only acquire it here
@@ -1413,7 +1423,7 @@
}
});
- build_minimal_symbol_hash_tables (m_objfile);
+ build_minimal_symbol_hash_tables (m_objfile, hash_values);
}
}
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: Ifaa3346e9998f05743bff9e2eaad3f83b954d071
Gerrit-Change-Number: 308
Gerrit-PatchSet: 3
Gerrit-Owner: Christian Biesinger <cbiesinger@google.com>
Gerrit-Reviewer: Tom Tromey <tromey@sourceware.org>
Gerrit-MessageType: newpatchset