]> git.ipfire.org Git - thirdparty/glibc.git/commit
x86_64: Remove avx512 strstr implementation
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Thu, 21 Mar 2024 17:12:00 +0000 (14:12 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Wed, 27 Mar 2024 16:48:16 +0000 (13:48 -0300)
commit721314c980ed371d36a84f63c393e4289e249b3b
treed472163c71d71a7846e52a9481da8e6a3ebe44e2
parent2e53eb923486704b7a0d6f3d81d1ee8ba672a56b
x86_64: Remove avx512 strstr implementation

As indicated in a recent thread, this it is a simple brute-force
algorithm that checks the whole needle at a matching character pair
(and does so 1 byte at a time after the first 64 bytes of a needle).
Also it never skips ahead and thus can match at every haystack
position after trying to match all of the needle, which generic
implementation avoids.

As indicated by Wilco, a 4x larger needle and 16x larger haystack gives
a clear 65x slowdown both basic_strstr and __strstr_avx512:

  "ifuncs": ["basic_strstr", "twoway_strstr", "__strstr_avx512",
"__strstr_sse2_unaligned", "__strstr_generic"],

    {
     "len_haystack": 65536,
     "len_needle": 1024,
     "align_haystack": 0,
     "align_needle": 0,
     "fail": 1,
     "desc": "Difficult bruteforce needle",
     "timings": [4.0948e+07, 15094.5, 3.20818e+07, 108558, 10839.2]
    },
    {
     "len_haystack": 1048576,
     "len_needle": 4096,
     "align_haystack": 0,
     "align_needle": 0,
     "fail": 1,
     "desc": "Difficult bruteforce needle",
     "timings": [2.69767e+09, 100797, 2.08535e+09, 495706, 82666.9]
    }

PS: I don't have an AVX512 capable machine to verify this issues, but
    skimming through the code it does seems to follow what Wilco has
    described.
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
sysdeps/x86_64/multiarch/Makefile
sysdeps/x86_64/multiarch/ifunc-impl-list.c
sysdeps/x86_64/multiarch/strstr-avx512.c [deleted file]
sysdeps/x86_64/multiarch/strstr.c