From patchwork Fri Nov 22 17:44:07 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: 36127 Received: (qmail 34679 invoked by alias); 22 Nov 2019 17:44:16 -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 34671 invoked by uid 89); 22 Nov 2019 17:44:15 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 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; Fri, 22 Nov 2019 17:44:14 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id A5581204BA; Fri, 22 Nov 2019 12:44:12 -0500 (EST) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [8.43.85.239]) by mx1.osci.io (Postfix) with ESMTP id E330A2030C; Fri, 22 Nov 2019 12:44:07 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id C756028172; Fri, 22 Nov 2019 12:44:07 -0500 (EST) X-Gerrit-PatchSet: 3 Date: Fri, 22 Nov 2019 12:44:07 -0500 From: "Sourceware to Gerrit sync (Code Review)" To: Christian Biesinger , gdb-patches@sourceware.org Cc: Kevin Buettner , Simon Marchi Auto-Submitted: auto-generated X-Gerrit-MessageType: merged Subject: [pushed] Create a correctly-sized demangled names hashtable X-Gerrit-Change-Id: I1f074d38e1d90af58705ec852f90c84cc034cd2e X-Gerrit-Change-Number: 686 X-Gerrit-ChangeURL: X-Gerrit-Commit: f8bab2d61d84b4e122ca667c4e458cd2ca29e3b6 In-Reply-To: References: Reply-To: noreply@gnutoolchain-gerrit.osci.io, simon.marchi@polymtl.ca, cbiesinger@google.com, kevinb@redhat.com, gdb-patches@sourceware.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3-79-g83ff7f88f1 Message-Id: <20191122174407.C756028172@gnutoolchain-gerrit.osci.io> Sourceware to Gerrit sync has submitted this change. 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 size it, so we don't have to resize/rehash it as much. This is a 6% improvement in minsym loading time. 2019-11-22 Christian Biesinger * symtab.c (create_demangled_names_hash): Use per_bfd-> minimal_symbol_count for computing the initial size, if greater than our default size. Change-Id: I1f074d38e1d90af58705ec852f90c84cc034cd2e --- M gdb/ChangeLog M gdb/symtab.c 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 93258c3..838262e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2019-11-22 Christian Biesinger + + * symtab.c (create_demangled_names_hash): Use per_bfd-> + minimal_symbol_count for computing the initial size, if greater + than our default size. + 2019-11-22 Tom de Vries * contrib/words.sh: Improve words extraction. diff --git a/gdb/symtab.c b/gdb/symtab.c index 0064800..6affdef 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -770,10 +770,20 @@ /* 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 a count + based on that, 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. */ + + /* htab will expand the table when it is 3/4th full, so we account for that + here. +2 to round up. */ + int minsym_based_count = (per_bfd->minimal_symbol_count + 2) / 3 * 4; + int count = std::max (per_bfd->minimal_symbol_count, minsym_based_count); 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)); }