From: "Sourceware to Gerrit sync (Code Review)" <gerrit@gnutoolchain-gerrit.osci.io>
To: Christian Biesinger <cbiesinger@google.com>, gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@sourceware.org>
Subject: [pushed] Compute msymbol hash codes in parallel
Date: Wed, 27 Nov 2019 21:40:00 -0000 [thread overview]
Message-ID: <20191127214007.7B44128173@gnutoolchain-gerrit.osci.io> (raw)
In-Reply-To: <gerrit.1572031795000.Ifaa3346e9998f05743bff9e2eaad3f83b954d071@gnutoolchain-gerrit.osci.io>
Sourceware to Gerrit sync has submitted this change.
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-11-27 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/ChangeLog
M gdb/minsyms.c
2 files changed, 41 insertions(+), 15 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index c278a77..64c8ab5 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,15 @@
2019-11-27 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.
+
+2019-11-27 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
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 141c3d2..94240c9 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 (sym->linkage_name ()) % 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),
- sym->search_name ());
-
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;
}
@@ -1266,6 +1264,10 @@
size_t name_length;
/* Hash code (using fast_hash) of the linkage_name. */
hashval_t mangled_name_hash;
+ /* The msymbol_hash of the linkage_name. */
+ unsigned int minsym_hash;
+ /* The msymbol_hash of the search_name. */
+ unsigned int minsym_demangled_hash;
};
/* Build (or rebuild) the minimal symbol hash tables. This is necessary
@@ -1273,23 +1275,28 @@
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;
/* (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 (msym->search_name () != msym->linkage_name ())
- add_minsym_to_demangled_hash_table (msym, objfile);
+ add_minsym_to_demangled_hash_table
+ (msym, objfile, hash_values[i].minsym_demangled_hash);
}
}
@@ -1404,6 +1411,15 @@
hash_values[idx].mangled_name_hash
= fast_hash (msym->name, hash_values[idx].name_length);
}
+ hash_values[idx].minsym_hash
+ = msymbol_hash (msym->linkage_name ());
+ /* We only use this hash code if the search name differs
+ from the linkage name. See the code in
+ build_minimal_symbol_hash_tables. */
+ if (msym->search_name () != msym->linkage_name ())
+ hash_values[idx].minsym_demangled_hash
+ = search_name_hash (MSYMBOL_LANGUAGE (msym),
+ msym->search_name ());
}
{
/* To limit how long we hold the lock, we only acquire it here
@@ -1425,7 +1441,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: 8
Gerrit-Owner: Christian Biesinger <cbiesinger@google.com>
Gerrit-Reviewer: Christian Biesinger <cbiesinger@google.com>
Gerrit-Reviewer: Tom Tromey <tromey@sourceware.org>
Gerrit-MessageType: merged
prev parent reply other threads:[~2019-11-27 21:40 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-25 19:30 [review] " Christian Biesinger (Code Review)
2019-10-29 19:44 ` Tom Tromey (Code Review)
2019-10-29 21:56 ` [review v3] " Christian Biesinger (Code Review)
2019-10-29 21:56 ` [review v2] " Christian Biesinger (Code Review)
2019-10-31 0:23 ` [review v4] " Christian Biesinger (Code Review)
2019-11-26 21:44 ` [review v5] " Christian Biesinger (Code Review)
2019-11-26 22:14 ` Tom Tromey (Code Review)
2019-11-26 22:23 ` [review v6] " Christian Biesinger (Code Review)
2019-11-26 22:25 ` Christian Biesinger (Code Review)
2019-11-26 22:27 ` [review v7] " Christian Biesinger (Code Review)
2019-11-27 18:04 ` Tom Tromey (Code Review)
2019-11-27 21:40 ` [pushed] " Sourceware to Gerrit sync (Code Review)
2019-11-27 21:40 ` Sourceware to Gerrit sync (Code Review) [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191127214007.7B44128173@gnutoolchain-gerrit.osci.io \
--to=gerrit@gnutoolchain-gerrit.osci.io \
--cc=cbiesinger@google.com \
--cc=gdb-patches@sourceware.org \
--cc=noreply@gnutoolchain-gerrit.osci.io \
--cc=tromey@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).