From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11847 invoked by alias); 8 Nov 2017 11:42:31 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 11829 invoked by uid 89); 8 Nov 2017 11:42:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=intern, Hx-languages-length:2545, love X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 08 Nov 2017 11:42:29 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A4A6A2C971C; Wed, 8 Nov 2017 11:42:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A4A6A2C971C Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=palves@redhat.com Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id EF1026BF81; Wed, 8 Nov 2017 11:42:27 +0000 (UTC) Subject: Re: [RFA 2/2] Simplify the psymbol hash function To: Tom Tromey , gdb-patches@sourceware.org References: <20171104161356.17565-1-tom@tromey.com> <20171104161356.17565-3-tom@tromey.com> <92a5383c-5fd0-baee-fbaa-977669a3c613@redhat.com> From: Pedro Alves Message-ID: <2981cbf6-e953-3f07-70d8-eac3ac78145e@redhat.com> Date: Wed, 08 Nov 2017 11:42:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <92a5383c-5fd0-baee-fbaa-977669a3c613@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-11/txt/msg00168.txt.bz2 On 11/08/2017 11:12 AM, Pedro Alves wrote: > On 11/04/2017 04:13 PM, Tom Tromey wrote: >> 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 presumably ok because symbol names are generally interned. > > Can you expand a bit more on the "presumably ok" part? I think > it'd be nice to mention/explain this assumption in a comment > in the code. > >> 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. > > That sounds great however I do wonder whether the bug is the other > way around though. What do the statistics say, e.g., debugging > gdb and firefox? Do we end up deduping more or fewer > symbols in the bcache? TBC, here I meant compared to changing the compare function to do strcmp instead of the pointer comparison. > > I read the original thread that added these custom functions, > and the original patch used strcmp in both hash and compare, > and then somehow the end result was what we have today. > > See: > https://sourceware.org/ml/gdb-patches/2010-08/msg00218.html > and: > https://sourceware.org/ml/gdb-patches/2010-08/msg00242.html > > So I'd love it that your patch is correct. I'd just appreciate > a bit more detail since I'm not awfully familiar with this area. BTW, I didn't quite get it the first time, but I think Sami's comment at: https://sourceware.org/ml/gdb-patches/2010-08/msg00242.html > "that explains how the old hash function worked" is related to this: https://sourceware.org/ml/gdb-patches/2010-08/msg00245.html > "A previous patch of mine introduced a bcache regression :D. The > patch made cplus_specifc a pointer to an allocated struct. This is > because we wanted to store more information in cplus_specific without > penalizing the other other languages. With cplus_specific being a > pointer hashing the whole symbol didn't work anymore. This patch is > an attempt to fix that. So before Sami's "previous patch", it sounds like we were already doing pointer comparisons, simply because we hashed the whole symbol as a block of memory. So now I'm thinking that your patch must be correct. I'd still like to learn more about where is it that we intern the symbol names, though, and I still think it'd be great to add a comment to the code. Thanks, Pedro Alves