From patchwork Tue Nov 26 22:23:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Simon Marchi (Code Review)" X-Patchwork-Id: 36278 Received: (qmail 91481 invoked by alias); 26 Nov 2019 22:23:31 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 91421 invoked by uid 89); 26 Nov 2019 22:23:31 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN autolearn=ham version=3.3.1 spammy= X-HELO: mx1.osci.io Received: from polly.osci.io (HELO mx1.osci.io) (8.43.85.229) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 26 Nov 2019 22:23:29 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id 2C90F2030C; Tue, 26 Nov 2019 17:23:28 -0500 (EST) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [IPv6:2620:52:3:1:5054:ff:fe06:16ca]) by mx1.osci.io (Postfix) with ESMTP id B764520387; Tue, 26 Nov 2019 17:23:25 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id 9C6EB28173; Tue, 26 Nov 2019 17:23:25 -0500 (EST) X-Gerrit-PatchSet: 6 Date: Tue, 26 Nov 2019 17:23:24 -0500 From: "Christian Biesinger (Code Review)" To: Christian Biesinger , Tom Tromey , gdb-patches@sourceware.org Auto-Submitted: auto-generated X-Gerrit-MessageType: newpatchset Subject: [review v6] Compute msymbol hash codes in parallel X-Gerrit-Change-Id: Ifaa3346e9998f05743bff9e2eaad3f83b954d071 X-Gerrit-Change-Number: 308 X-Gerrit-ChangeURL: X-Gerrit-Commit: 14f40f2698dfd21ffccffd8c27ed1a9cd0873129 In-Reply-To: References: Reply-To: cbiesinger@google.com, tromey@sourceware.org, cbiesinger@google.com, gdb-patches@sourceware.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3-79-g83ff7f88f1 Message-Id: <20191126222325.9C6EB28173@gnutoolchain-gerrit.osci.io> 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 * 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) : Add these fields. Change-Id: Ifaa3346e9998f05743bff9e2eaad3f83b954d071 --- M gdb/minsyms.c 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 141c3d2..14d15b3 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& 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); } }