public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Torbjorn SVENSSON <torbjorn.svensson@foss.st.com>
To: Eli Zaretskii <eliz@gnu.org>, Simon Marchi <simark@simark.ca>
Cc: <cbiesinger@google.com>, <tom@tromey.com>,
	<gdb-patches@sourceware.org>, <luis.machado@arm.com>
Subject: Re: Two observations using GDB 13 snapshot
Date: Thu, 5 Jan 2023 19:06:55 +0100	[thread overview]
Message-ID: <a8100d55-0c98-dba6-b783-5d614a96da39@foss.st.com> (raw)
In-Reply-To: <831qoayxuu.fsf@gnu.org>



On 2023-01-04 19:10, Eli Zaretskii via Gdb-patches wrote:
>> Date: Tue, 3 Jan 2023 16:34:53 -0500
>> Cc: tom@tromey.com, gdb-patches@sourceware.org, luis.machado@arm.com
>> From: Simon Marchi <simark@simark.ca>
>>
>>> 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=<optimized out>, __s1=<optimized out>)
>>      at d:/usr/include/strings.h:92
>> #6  cooked_index_entry::operator< (this=<optimized out>, 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;

Without any knowledge of the cooked_index_entry type or what it's 
supposed to do, I think the return statement here is problematic in the 
case where there are 2 cooked_index_entry instances contains the same 
case insensitive canonical strings. I'm not sure if this can happen, but 
it's just a thought.
It also appears that the old strcasecmp implementation would suffer the 
same limitation. To avoid the issue, I guess the address of the 2 
objects could be compared in order to get a stable result if there is no 
other property that is guaranteed to be unique for the 2 instances.

Kind regards,
Torbjörn

> +	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

  parent reply	other threads:[~2023-01-05 18:07 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-17 17:42 Eli Zaretskii
2022-12-19 10:07 ` Luis Machado
2022-12-19 12:48   ` Eli Zaretskii
2022-12-19 14:08     ` Luis Machado
2022-12-19 14:45       ` Eli Zaretskii
2022-12-19 21:18         ` Tom Tromey
2022-12-20  3:26           ` Eli Zaretskii
2022-12-23  3:34             ` Simon Marchi
2022-12-23  8:05               ` Eli Zaretskii
2022-12-24 17:57             ` Tom Tromey
2022-12-24 18:13               ` Eli Zaretskii
2022-12-27 17:19                 ` Tom Tromey
2022-12-27 18:00                   ` Eli Zaretskii
2022-12-28 12:35                     ` Luis Machado
2022-12-28 16:35                     ` Tom Tromey
2022-12-28 17:35                       ` Eli Zaretskii
2022-12-28 22:47                         ` Tom Tromey
2022-12-29 15:18                           ` Eli Zaretskii
2022-12-29 18:17                             ` Tom Tromey
2022-12-29 18:36                               ` John Baldwin
2022-12-29 19:13                               ` Eli Zaretskii
2022-12-29 20:22                                 ` Simon Marchi
2022-12-30 14:31                                   ` Eli Zaretskii
2023-01-03 19:44                                     ` Christian Biesinger
2023-01-03 20:18                                       ` Eli Zaretskii
2023-01-03 20:34                                         ` Christian Biesinger
2023-01-03 21:34                                           ` Simon Marchi
2023-01-03 21:43                                             ` Christian Biesinger
2023-01-04  1:03                                             ` Tom Tromey
2023-01-04 18:10                                             ` Eli Zaretskii
2023-01-04 22:33                                               ` Tom Tromey
2023-01-05  7:11                                                 ` Eli Zaretskii
2023-01-05 14:49                                                   ` Christian Biesinger
2023-01-05 15:12                                                     ` Eli Zaretskii
2023-01-06 20:55                                                   ` Tom Tromey
2023-01-05 18:06                                               ` Torbjorn SVENSSON [this message]
2023-01-07  6:30 ` Eli Zaretskii
2023-01-07  9:14   ` Andreas Schwab
2023-01-07  9:32     ` Eli Zaretskii
2023-01-07 10:00       ` Andreas Schwab
2023-01-07 10:51         ` Eli Zaretskii
2023-01-07 13:04           ` Andreas Schwab
2023-01-07 13:54             ` Eli Zaretskii
2023-01-07 13:59               ` Andreas Schwab
2023-01-07 14:12                 ` Eli Zaretskii
2023-01-07 14:23                   ` Andreas Schwab
2023-01-07 14:29                     ` Eli Zaretskii
2023-01-07 14:40                       ` Andreas Schwab
2023-01-07 15:07                         ` Eli Zaretskii
2023-01-07 15:40                           ` Andreas Schwab
2023-01-07 16:10                             ` Eli Zaretskii
2023-01-07 16:15                               ` Eli Zaretskii
2023-01-07 16:16                               ` Hannes Domani
2023-01-07 16:22                                 ` Eli Zaretskii
2023-01-07 17:39                                 ` Andreas Schwab
2023-01-07 18:08                                   ` Eli Zaretskii
2023-01-07 18:26                                     ` Andreas Schwab
2023-01-07 18:38                                       ` Eli Zaretskii
2023-01-07 19:26                                         ` Andreas Schwab
2023-01-07 19:35                                           ` Eli Zaretskii
2023-01-07 18:28                                     ` Hannes Domani
2023-01-07 19:25                                       ` Andreas Schwab
2023-01-07 15:07                       ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a8100d55-0c98-dba6-b783-5d614a96da39@foss.st.com \
    --to=torbjorn.svensson@foss.st.com \
    --cc=cbiesinger@google.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=luis.machado@arm.com \
    --cc=simark@simark.ca \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).