From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id wHoxOS3BtWOXTw8AWB0awg (envelope-from ) for ; Wed, 04 Jan 2023 13:10:53 -0500 Received: by simark.ca (Postfix, from userid 112) id E80071E222; Wed, 4 Jan 2023 13:10:53 -0500 (EST) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=Gk/K2Mqh; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-8.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 8FEF81E112 for ; Wed, 4 Jan 2023 13:10:53 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3A9863858C52 for ; Wed, 4 Jan 2023 18:10:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3A9863858C52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1672855853; bh=3836vQFVWF8AcRHg/Uky83PK/3zWTqCOBNz4Q7BoCPA=; h=Date:To:Cc:In-Reply-To:Subject:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=Gk/K2MqhuvAODehV6HQ8aIG9XIL4MheShFluBNpw3WLK5einY2Xi1HfWYMQ+u5FfU c/kg6OBSfLcJf4jMtjlbKhD200k4OkuYWcz4GFn8LX97NAtXlIIdHw+L9kTudfo7r3 PTOOHETecdmmUminVBE5a7FHfDIXNTu5vjWyzSB0= 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 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 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> 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-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Eli Zaretskii via Gdb-patches Reply-To: Eli Zaretskii Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" > 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