From patchwork Thu Nov 9 14:09:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 24182 Received: (qmail 39434 invoked by alias); 9 Nov 2017 14:09:25 -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 39400 invoked by uid 89); 9 Nov 2017 14:09:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: gateway20.websitewelcome.com Received: from gateway20.websitewelcome.com (HELO gateway20.websitewelcome.com) (192.185.52.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 09 Nov 2017 14:09:22 +0000 Received: from cm15.websitewelcome.com (cm15.websitewelcome.com [100.42.49.9]) by gateway20.websitewelcome.com (Postfix) with ESMTP id A3C1240107517 for ; Thu, 9 Nov 2017 08:09:20 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id CnWCesMJ95b6TCnWCe63Cx; Thu, 09 Nov 2017 08:09:20 -0600 Received: from 71-218-90-63.hlrn.qwest.net ([71.218.90.63]:53660 helo=bapiya) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1eCnWC-000GIH-Bw; Thu, 09 Nov 2017 08:09:20 -0600 From: Tom Tromey To: Tom Tromey Cc: Pedro Alves , gdb-patches@sourceware.org Subject: Re: [RFA 2/2] Simplify the psymbol hash function References: <20171104161356.17565-1-tom@tromey.com> <20171104161356.17565-3-tom@tromey.com> <92a5383c-5fd0-baee-fbaa-977669a3c613@redhat.com> <2981cbf6-e953-3f07-70d8-eac3ac78145e@redhat.com> <87tvy4r3k4.fsf@tromey.com> Date: Thu, 09 Nov 2017 07:09:19 -0700 In-Reply-To: <87tvy4r3k4.fsf@tromey.com> (Tom Tromey's message of "Wed, 08 Nov 2017 12:08:43 -0700") Message-ID: <87efp7r1bk.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.60 (gnu/linux) MIME-Version: 1.0 X-BWhitelist: no X-Source-L: No X-Exim-ID: 1eCnWC-000GIH-Bw X-Source-Sender: 71-218-90-63.hlrn.qwest.net (bapiya) [71.218.90.63]:53660 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes >>>>> "Tom" == Tom Tromey writes: Tom> I can add comments to the psymbol hash and comparison functions to Tom> mention this. How's this? Tom commit a042125cb391b1b489f272353a4c90068fc92954 Author: Tom Tromey Date: Thu Nov 2 12:48:44 2017 -0600 Simplify the psymbol hash function This patch simplifies the psymbol_hash function, by changing it not to examine the contents of the symbol's name. This change just mirrors what psymbol_compare already does -- it is checking for name equality, which is ok because symbol names are interned in symbol_set_names. This change speeds up psymbol reading. "gdb -nx -batch gdb" previously took ~1.8 seconds on my machine, and with this patch it now takes ~1.7 seconds. gdb/ChangeLog 2017-11-09 Tom Tromey * psymtab.c (psymbol_hash): Do not hash string contents. (psymbol_compare): Add comment. diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 03ccf9d57c..014ae04a3d 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2017-11-09 Tom Tromey + + * psymtab.c (psymbol_hash): Do not hash string contents. + (psymbol_compare): Add comment. + 2017-11-04 Tom Tromey * dictionary.c (dict_hash): Move "TKB" check into the "switch". diff --git a/gdb/psymtab.c b/gdb/psymtab.c index 29d40dcc04..06a65bf26e 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -1548,7 +1548,9 @@ psymbol_hash (const void *addr, int length) h = hash_continue (&lang, sizeof (unsigned int), h); h = hash_continue (&domain, sizeof (unsigned int), h); h = hash_continue (&theclass, sizeof (unsigned int), h); - h = hash_continue (psymbol->ginfo.name, strlen (psymbol->ginfo.name), h); + /* Note that psymbol names are interned via symbol_set_names, so + there's no need to hash the contents of the name here. */ + h = hash_continue (&psymbol->ginfo.name, sizeof (psymbol->ginfo.name), h); return h; } @@ -1568,6 +1570,9 @@ psymbol_compare (const void *addr1, const void *addr2, int length) && sym1->ginfo.language == sym2->ginfo.language && PSYMBOL_DOMAIN (sym1) == PSYMBOL_DOMAIN (sym2) && PSYMBOL_CLASS (sym1) == PSYMBOL_CLASS (sym2) + /* Note that psymbol names are interned via + symbol_set_names, so there's no need to compare the + contents of the name here. */ && sym1->ginfo.name == sym2->ginfo.name); }