From: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
To: Andy Shevchenko <andy.shevchenko@gmail.com>,
Nathan Moinvaziri <nathan@nathanm.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Andy Shevchenko <andy@kernel.org>
Subject: Re: [PATCH] lib/string.c: Improve strcasecmp speed by not lowering if chars match
Date: Tue, 25 Oct 2022 21:55:26 +0200 [thread overview]
Message-ID: <7695dbae-0fc6-d53c-5b9f-b3bd7e7fe8f8@prevas.dk> (raw)
In-Reply-To: <CAHp75Vd4Vk0v-T3kfxApGHb-H26KTHgH59DGP3Wm4qBgunDt6A@mail.gmail.com>
On 25/10/2022 10.00, Andy Shevchenko wrote:
> On Tue, Oct 25, 2022 at 4:46 AM Nathan Moinvaziri <nathan@nathanm.com> wrote:
>>
>> From fcb0159ee74908f92adc34143657d8ca56e9a811 Mon Sep 17 00:00:00 2001
>> From: Nathan Moinvaziri <nathan@nathanm.com>
>> Date: Mon, 24 Oct 2022 16:37:59 -0700
>> Subject: [PATCH] lib/string.c: Improve strcasecmp speed by not lowering if
>> chars match.
>
> Why is the above in the commit message?
>
>> With strings where many characters match exactly each character is needlessly
>> converted to lowercase before comparing. This patch improves the comparison
>> by only converting to lowercase after checking that the characters don't match.
>>
>> The more characters that match exactly the better performance we expect versus
>> the old function.
> You tell us that this is more preformant, but have not provided the
> numbers. Can we see those, please?
>
> Note, that you basically trash CPU cache lines when characters are not
> equal, and before doing that you have a branching. I'm unsure that
> your way is more performant than the original one.
>
Are there any code paths in the kernel where strcasecmp performance
matters? strcmp, sure, but strcasecmp or strncasecmp? I don't think so.
If anything, we should nuke the complication in strncasecmp(), and then
make strcasecmp() simply do strncasecmp(a, b, SIZE_MAX).
Rasmus
next prev parent reply other threads:[~2022-10-25 19:55 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-25 1:46 Nathan Moinvaziri
2022-10-25 8:00 ` Andy Shevchenko
2022-10-25 9:03 ` Andy Shevchenko
2022-10-25 17:53 ` Nathan Moinvaziri
2022-10-25 19:19 ` Andy Shevchenko
2022-10-27 3:29 ` Nathan Moinvaziri
2022-10-27 6:31 ` Andy Shevchenko
2022-10-25 19:32 ` Christophe JAILLET
2022-10-25 23:27 ` Nathan Moinvaziri
2022-10-25 19:55 ` Rasmus Villemoes [this message]
2022-10-25 22:37 ` Nathan Moinvaziri
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=7695dbae-0fc6-d53c-5b9f-b3bd7e7fe8f8@prevas.dk \
--to=rasmus.villemoes@prevas.dk \
--cc=andy.shevchenko@gmail.com \
--cc=andy@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nathan@nathanm.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
all inboxes | Powered by JetHome®