Message ID | gerrit.1574118864000.I1f074d38e1d90af58705ec852f90c84cc034cd2e@gnutoolchain-gerrit.osci.io |
---|---|
State | New, archived |
Headers |
Received: (qmail 36959 invoked by alias); 18 Nov 2019 23:14:42 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <gdb-patches.sourceware.org> List-Unsubscribe: <mailto:gdb-patches-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 36935 invoked by uid 89); 18 Nov 2019 23:14:41 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=minsym 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; Mon, 18 Nov 2019 23:14:31 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id 8F27620393; Mon, 18 Nov 2019 18:14:29 -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 5CB372013D; Mon, 18 Nov 2019 18:14:25 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id 344752816F; Mon, 18 Nov 2019 18:14:25 -0500 (EST) X-Gerrit-PatchSet: 1 Date: Mon, 18 Nov 2019 18:14:25 -0500 From: "Christian Biesinger (Code Review)" <gerrit@gnutoolchain-gerrit.osci.io> To: gdb-patches@sourceware.org Cc: Christian Biesinger <cbiesinger@google.com> Message-ID: <gerrit.1574118864000.I1f074d38e1d90af58705ec852f90c84cc034cd2e@gnutoolchain-gerrit.osci.io> Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange Subject: [review] Create a correctly-sized demangled names hashtable X-Gerrit-Change-Id: I1f074d38e1d90af58705ec852f90c84cc034cd2e X-Gerrit-Change-Number: 686 X-Gerrit-ChangeURL: <https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/686> X-Gerrit-Commit: b5f0fe2db448850c0d332a0cd644d36046d975ff References: <gerrit.1574118864000.I1f074d38e1d90af58705ec852f90c84cc034cd2e@gnutoolchain-gerrit.osci.io> Reply-To: cbiesinger@google.com, cbiesinger@google.com, gdb-patches@sourceware.org MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline User-Agent: Gerrit/3.0.3-79-g83ff7f88f1 Content-Type: text/plain; charset=UTF-8 |
Commit Message
Simon Marchi (Code Review)
Nov. 18, 2019, 11:14 p.m. UTC
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/686 ...................................................................... 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 create it, so we don't have to resize/rehash it as much. This is a 6% improvement in minsym loading time. 2019-11-18 Christian Biesinger <cbiesinger@google.com> * symtab.c (create_demangled_names_hash): Use per_bfd-> minimal_symbol_count as the initial size, if greater than our default size. Change-Id: I1f074d38e1d90af58705ec852f90c84cc034cd2e --- M gdb/symtab.c 1 file changed, 9 insertions(+), 2 deletions(-)
Comments
Christian Biesinger has posted comments on this change. Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/686 ...................................................................... Patch Set 1: I guess this patch doesn't *technically* depend on the threading changes; but it will have no benefit without them.
Christian Biesinger has posted comments on this change. Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/686 ...................................................................... Patch Set 1: (1 comment) | --- gdb/symtab.c | +++ gdb/symtab.c | @@ -771,10 +771,17 @@ create_demangled_names_hash (struct objfile_per_bfd_storage *per_bfd) | 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 that | + count, 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. */ | + | + int count = std::max (per_bfd->minimal_symbol_count, 256); PS1, Line 779: Looking at hashtab.c, I should perhaps do something like ((minimal_symbol_count+2)/3)*4, to more completely avoid hashtable resizings. Let me know if you have thoughts on that. | | 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)); | } | | /* See symtab.h */ |
Simon Marchi has posted comments on this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/686
......................................................................
Patch Set 1:
(1 comment)
| --- gdb/symtab.c
| +++ gdb/symtab.c
| @@ -771,10 +771,17 @@ create_demangled_names_hash (struct objfile_per_bfd_storage *per_bfd)
| 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 that
| + count, 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. */
| +
| + int count = std::max (per_bfd->minimal_symbol_count, 256);
PS1, Line 779:
> Looking at hashtab.c, I should perhaps do something like ((minimal_symbol_count+2)/3)*4, to more completely avoid hashtable resizings. Let me know if you have thoughts on that.
Not sure why the +2, but I think it's a good idea to size the
hashtable correctly from the start. I'd be fine with the (.../3)*4
with the comment explaining why we do that. This is performance
critical code, so it's normal to do tweaks like that.
Oh, is the +2 to make sure it rounds up the division by 3?
|
| 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));
| }
|
| /* See symtab.h */
|
Christian Biesinger has posted comments on this change. Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/686 ...................................................................... Patch Set 2: (1 comment) BTW, thoughts on me pushing this even without the threading changes, so that I have fewer patches to keep track of? Shouldn't hurt anything. | --- gdb/symtab.c | +++ gdb/symtab.c | @@ -771,10 +771,17 @@ create_demangled_names_hash (struct objfile_per_bfd_storage *per_bfd) | 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 that | + count, 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. */ | + | + int count = std::max (per_bfd->minimal_symbol_count, 256); PS1, Line 779: Yes, +2 is for rounding. Done and added a comment for that. | | 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)); | } | | /* See symtab.h */ |
Kevin Buettner has posted comments on this change. Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/686 ...................................................................... Patch Set 2: Code-Review+2 > Patch Set 2: > > (1 comment) > > BTW, thoughts on me pushing this even without the threading changes, so that I have fewer patches to keep track of? Shouldn't hurt anything. I think it makes sense to push this patch ahead of the rest of the series.
diff --git a/gdb/symtab.c b/gdb/symtab.c index 3502827..e4da065 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -769,10 +769,17 @@ /* 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 that + count, 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. */ + + int count = std::max (per_bfd->minimal_symbol_count, 256); 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)); }