Intel Further Speeds Up strnlen() In The GNU C Library For Recent Intel/AMD CPUs

Written by Michael Larabel in Intel on 22 August 2024 at 06:26 AM EDT. 35 Comments
INTEL
Intel software engineers are responsible for many of the great x86_64-related optimizations to the GNU C Library "glibc" over the years. While they've extensively tuned many Glibc functions for achieving peak performance on their modern CPUs, it's a never-ending quest. Merged this week was another optimization to strnlen(), the function for determining the number of bytes in a fixed-size string.

Matthew Sterrett of Intel unified Glibc's strnlen EVEX and EVEX512 implementations. In turn this unified, optimized strnlen handling for x86_64 Intel/AMD CPUs with EVEX support is showing some nice improvements over the prior code.

Core i9 7900X


Sterrett wrote in the commit unifying the strnlen EVEX implementations:
x86: Unifies 'strnlen-evex' and 'strnlen-evex512' implementations.

This commit uses a common implementation 'strnlen-evex-base.S' for both 'strnlen-evex' and 'strnlen-evex512'

This patch serves both to reduce the number of implementations, and it also does some small optimizations that benefit strnlen-evex and strnlen-evex512.

All tests pass on x86.

Benchmarks were taken on [an Intel Core i9 7900X Skylake X CPU].

Geometric mean for strnlen-evex over all benchmarks (N=10) was (new/old) 0.881
Geometric mean for strnlen-evex512 over all benchmarks (N=10) was (new/old) 0.953

That improved code is merged in Glibc Git for the Glibc 2.41 release coming out as stable in February.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week