From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 047EF3858D35 for ; Wed, 4 Jan 2023 18:10:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 047EF3858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gnu.org Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pD8DY-0001Yu-Hp; Wed, 04 Jan 2023 13:10:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=3836vQFVWF8AcRHg/Uky83PK/3zWTqCOBNz4Q7BoCPA=; b=W9Mmrt+T5gUH bvu6TTJgQ0EZcniXTTwfjq82cZywmL4IsF93PFC0/i6MRF8Zc73lKzovLIFXwDFPeWCRYQSFPReUg C/ffgUzzb+k4bi0dSvPFyHjOk2WMod+55GxAMkEag+CiEMvtx5/KIKI3yoRTYlYUsvvfIrS0JksyR Aq7LKTAnrNOoNmiAihUcqgco0NwmkMdNH9RFlyKN0C4jBd7pfFUdV+jPTAU0bAlGyqUbvQHvJtTIt ZY9QsTmcuMBT/m52w2ADlXUtCgDsLHkBuHUWZyWdFhrL+lRuncCQeoEJUlE0JPaiJte2TiHE4qO2d wZAdpKiUN9V+/YPDxiEnUQ==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pD8DU-0003dI-Qq; Wed, 04 Jan 2023 13:10:23 -0500 Date: Wed, 04 Jan 2023 20:10:33 +0200 Message-Id: <831qoayxuu.fsf@gnu.org> From: Eli Zaretskii To: Simon Marchi Cc: cbiesinger@google.com, tom@tromey.com, gdb-patches@sourceware.org, luis.machado@arm.com In-Reply-To: <46d7fd4b-d5f0-0007-3e88-20345e0e0584@simark.ca> (message from Simon Marchi on Tue, 3 Jan 2023 16:34:53 -0500) Subject: Re: Two observations using GDB 13 snapshot References: <83h6xugc5v.fsf@gnu.org> <58b64bf8-90b6-d080-c060-d03761501199@arm.com> <83k02neezy.fsf@gnu.org> <835ye7e9jw.fsf@gnu.org> <87h6xrks77.fsf@tromey.com> <83mt7idacj.fsf@gnu.org> <87fsd4elb2.fsf@tromey.com> <83o7rs4qmg.fsf@gnu.org> <87cz84dasj.fsf@tromey.com> <835ydw20bw.fsf@gnu.org> <87wn6bbi5m.fsf@tromey.com> <83sfgz8m9i.fsf@gnu.org> <87o7rnb0ya.fsf@tromey.com> <83a6368chf.fsf@gnu.org> <87k02aaxc8.fsf@tromey.com> <83wn6a6n21.fsf@gnu.org> <587b899f-0f93-530a-7313-d4e1f9e501b9@simark.ca> <835ydt6jzw.fsf@gnu.org> <83wn63z81w.fsf@gnu.org> <46d7fd4b-d5f0-0007-3e88-20345e0e0584@simark.ca> X-Spam-Status: No, score=1.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_BARRACUDACENTRAL,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: > Date: Tue, 3 Jan 2023 16:34:53 -0500 > Cc: tom@tromey.com, gdb-patches@sourceware.org, luis.machado@arm.com > From: Simon Marchi > > > In terms of the code, may be worth trying TOLOWER from > > include/safe-ctype.h instead of tolower() > > The tolower call is inside strcasecmp, we don't call tolower directly: > > #0 0x77c348d5 in msvcrt!__crtLCMapStringA () > from C:\WINDOWS\system32\msvcrt.dll > #1 0x77c348cd in msvcrt!__crtLCMapStringA () > from C:\WINDOWS\system32\msvcrt.dll > #2 0x77c30045 in wmktemp () from C:\WINDOWS\system32\msvcrt.dll > #3 0x77c1c992 in tolower () from C:\WINDOWS\system32\msvcrt.dll > #4 0x77c462a1 in stricmp () from C:\WINDOWS\system32\msvcrt.dll > #5 0x005107d3 in strcasecmp (__s2=, __s1=) > at d:/usr/include/strings.h:92 > #6 cooked_index_entry::operator< (this=, other=...) > at ./dwarf2/cooked-index.h:150 > > It would be interesting to change that strcasecmp call to strcmp, just > to see if it makes an impact on the performance. Whether or not that > would be correct is another thing, but it would help see if that > strcasecmp / tolower call is really at fault here. Looks like indeed strcasecmp is the culprit. With the patch below, which replaces strcasecmp with a simple case-insensitive comparison that only works with ASCII, the phase of reading symbols from gdb.exe goes down to just 6 seconds, which is basically the same time as with GDB 12. --- gdb/dwarf2/cooked-index.h~0 2022-12-17 03:47:12.000000000 +0200 +++ gdb/dwarf2/cooked-index.h 2023-01-04 20:00:04.052250000 +0200 @@ -35,6 +35,8 @@ #include "dwarf2/tag.h" #include "gdbsupport/range-chain.h" +#define my_tolower(c) (('A' <= (c) && (c) <= 'Z') ? ((c) - 'A' + 'a') : (c)) + struct dwarf2_per_cu_data; /* Flags that describe an entry in the index. */ @@ -147,7 +149,20 @@ struct cooked_index_entry : public alloc entries. */ bool operator< (const cooked_index_entry &other) const { +#if 0 return strcasecmp (canonical, other.canonical) < 0; +#else + const unsigned char *s1 = (unsigned char *)canonical, *s2 = (unsigned char *)other.canonical; + + while (my_tolower(*s1) == my_tolower(*s2)) + { + if (*s1 == 0) + return false; + s1++; + s2++; + } + return (int)my_tolower(*s1) < (int)my_tolower(*s2); +#endif } /* The name as it appears in DWARF. This always points into one of