Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 7 Aug 2023 00:20:18 +0100
From:      Jessica Clarke <jrtc27@freebsd.org>
To:        Robert Clausecker <fuz@FreeBSD.org>
Cc:        "src-committers@freebsd.org" <src-committers@FreeBSD.org>, "dev-commits-src-all@freebsd.org" <dev-commits-src-all@FreeBSD.org>, "dev-commits-src-main@freebsd.org" <dev-commits-src-main@FreeBSD.org>
Subject:   Re: git: 61f4c4d3dd38 - main - lib/libc/amd64/string: add strchrnul implementations (scalar, baseline)
Message-ID:  <EDA62808-A149-456C-8659-C37B74791D1B@freebsd.org>
In-Reply-To: <202308061410.376EA6WM096467@gitrepo.freebsd.org>
References:  <202308061410.376EA6WM096467@gitrepo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 6 Aug 2023, at 15:10, Robert Clausecker <fuz@FreeBSD.org> wrote:
>=20
> The branch main has been updated by fuz:
>=20
> URL: =
https://cgit.FreeBSD.org/src/commit/?id=3D61f4c4d3dd38c5b79e04fff1dedb0207=
1ebb33f2
>=20
> commit 61f4c4d3dd38c5b79e04fff1dedb02071ebb33f2
> Author:     Robert Clausecker <fuz@FreeBSD.org>
> AuthorDate: 2023-06-30 14:45:11 +0000
> Commit:     Robert Clausecker <fuz@FreeBSD.org>
> CommitDate: 2023-08-06 13:58:27 +0000
>=20
>    lib/libc/amd64/string: add strchrnul implementations (scalar, =
baseline)
>=20
>    A lot better than the generic (pre) implementaion.  We do not beat =
glibc
>    for long strings, likely due to glibc switching to AVX once the =
input is
>    sufficiently long.  X86-64-v3 and v4 implementations may be added =
at a
>    future time.
>=20
>    os: FreeBSD
>    arch: amd64
>    cpu: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
>            =E2=94=82 strchrnul_pre.out =E2=94=82         =
strchrnul_scalar.out         =E2=94=82       strchrnul_baseline.out      =
  =E2=94=82
>            =E2=94=82      sec/op       =E2=94=82    sec/op     vs base =
               =E2=94=82   sec/op     vs base                =E2=94=82
>    Short          129.68=C2=B5 =C2=B1 3%    59.91=C2=B5 =C2=B1 1%  =
-53.80% (p=3D0.000 n=3D20)   44.37=C2=B5 =C2=B1 1%  -65.79% (p=3D0.000 =
n=3D20)
>    Mid             21.15=C2=B5 =C2=B1 0%    19.30=C2=B5 =C2=B1 0%   =
-8.76% (p=3D0.000 n=3D20)   12.30=C2=B5 =C2=B1 0%  -41.85% (p=3D0.000 =
n=3D20)
>    Long           13.772=C2=B5 =C2=B1 0%   11.028=C2=B5 =C2=B1 0%  =
-19.92% (p=3D0.000 n=3D20)   3.285=C2=B5 =C2=B1 0%  -76.15% (p=3D0.000 =
n=3D20)
>    geomean         33.55=C2=B5         23.36=C2=B5       -30.37%       =
           12.15=C2=B5       -63.80%
>=20
>            =E2=94=82 strchrnul_pre.out =E2=94=82          =
strchrnul_scalar.out          =E2=94=82         strchrnul_baseline.out   =
      =E2=94=82
>            =E2=94=82        B/s        =E2=94=82      B/s       vs =
base                 =E2=94=82      B/s       vs base                 =
=E2=94=82
>    Short          919.3Mi =C2=B1 3%   1989.7Mi =C2=B1 1%  +116.45% =
(p=3D0.000 n=3D20)   2686.8Mi =C2=B1 1%  +192.28% (p=3D0.000 n=3D20)
>    Mid            5.505Gi =C2=B1 0%    6.033Gi =C2=B1 0%    +9.60% =
(p=3D0.000 n=3D20)    9.466Gi =C2=B1 0%   +71.97% (p=3D0.000 n=3D20)
>    Long           8.453Gi =C2=B1 0%   10.557Gi =C2=B1 0%   +24.88% =
(p=3D0.000 n=3D20)   35.441Gi =C2=B1 0%  +319.26% (p=3D0.000 n=3D20)
>    geomean        3.470Gi         4.983Gi        +43.62%               =
    9.584Gi       +176.22%
>=20
>    For comparison, glibc on the same machine:
>=20
>            =E2=94=82 strchrnul_glibc.out =E2=94=82
>            =E2=94=82       sec/op        =E2=94=82
>    Short             49.73=C2=B5 =C2=B1 0%
>    Mid               14.60=C2=B5 =C2=B1 0%
>    Long              1.237=C2=B5 =C2=B1 0%
>    geomean           9.646=C2=B5
>=20
>            =E2=94=82 strchrnul_glibc.out =E2=94=82
>            =E2=94=82         B/s         =E2=94=82
>    Short            2.341Gi =C2=B1 0%
>    Mid              7.976Gi =C2=B1 0%
>    Long             94.14Gi =C2=B1 0%
>    geomean          12.07Gi
>=20
>    Sponsored by:   The FreeBSD Foundation
>    Approved by:    mjg
>    Differential Revision: https://reviews.freebsd.org/D41333
> ---
> lib/libc/amd64/string/Makefile.inc |   1 +
> lib/libc/amd64/string/strchrnul.S  | 167 =
+++++++++++++++++++++++++++++++++++++
> 2 files changed, 168 insertions(+)
>=20
> diff --git a/lib/libc/amd64/string/Makefile.inc =
b/lib/libc/amd64/string/Makefile.inc
> index 1bfefa7be98c..b5260cfd78d1 100644
> --- a/lib/libc/amd64/string/Makefile.inc
> +++ b/lib/libc/amd64/string/Makefile.inc
> @@ -8,6 +8,7 @@ MDSRCS+=3D \
> memmove.S \
> memset.S \
> strcat.S \
> + strchrnul.S \
> strcmp.S \
> strlen.S \
> stpcpy.S
> diff --git a/lib/libc/amd64/string/strchrnul.S =
b/lib/libc/amd64/string/strchrnul.S
> new file mode 100644
> index 000000000000..6d22f31850f8
> --- /dev/null
> +++ b/lib/libc/amd64/string/strchrnul.S
> @@ -0,0 +1,167 @@
> +/*-
> + * Copyright (c) 2023 The FreeBSD Foundation
> + *
> + * This software was developed by Robert Clausecker <fuz@FreeBSD.org>
> + * under sponsorship from the FreeBSD Foundation.
> + *
> + * Redistribution and use in source and binary forms, with or without
> + * modification, are permitted provided that the following conditions
> + * are met:
> + * 1. Redistributions of source code must retain the above copyright
> + *    notice, this list of conditions and the following disclaimer.
> + * 2. Redistributions in binary form must reproduce the above =
copyright
> + *    notice, this list of conditions and the following disclaimer in =
the
> + *    documentation and/or other materials provided with the =
distribution.
> + *
> + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ''AS IS'' =
AND
> + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, =
THE
> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR =
PURPOSE
> + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE =
LIABLE
> + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR =
CONSEQUENTIAL
> + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE =
GOODS
> + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS =
INTERRUPTION)
> + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN =
CONTRACT, STRICT
> + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN =
ANY WAY
> + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE =
POSSIBILITY OF
> + * SUCH DAMAGE
> + */
> +
> +#include <machine/asm.h>
> +
> +#include "amd64_archlevel.h"
> +
> +#define ALIGN_TEXT .p2align 4,0x90 # 16-byte alignment, nop-filled
> +
> + .weak strchrnul
> + .set strchrnul, __strchrnul
> +
> +ARCHFUNCS(__strchrnul)
> +        ARCHFUNC(__strchrnul, scalar)

This line specifically is using spaces not a tab for indentation.

Jess




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?EDA62808-A149-456C-8659-C37B74791D1B>