lkml.org 
[lkml]   [2022]   [Oct]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] lib/string.c: Improve strcasecmp speed by not lowering if chars match
From
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

\
 
 \ /
  Last update: 2022-10-25 21:56    [W:0.133 / U:0.808 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site