Page MenuHomeFreeBSD

lib/libc/amd64/string: add memchr(3) scalar, baseline implementation
ClosedPublic

Authored by fuz on Aug 25 2023, 11:03 PM.
Tags
None
Referenced Files
F96644616: D41598.diff
Wed, Sep 25, 9:17 PM
Unknown Object (File)
Mon, Sep 23, 2:48 PM
Unknown Object (File)
Wed, Sep 18, 7:20 AM
Unknown Object (File)
Wed, Sep 18, 4:17 AM
Unknown Object (File)
Tue, Sep 17, 12:34 PM
Unknown Object (File)
Mon, Sep 16, 10:06 PM
Unknown Object (File)
Sun, Sep 15, 8:38 PM
Unknown Object (File)
Sat, Sep 14, 6:01 AM
Subscribers

Details

Summary

This is conceptually similar to strchr(3), but there are
slight changes to account for the buffer having an explicit
buffer length.

Now that we have an optimised memchr(3), we can use it
to implement strnlen(3) with better performance. This
could perhaps be backported to the generic implementation
as strnlen(3) isn't optimised there but memchr(3) is.

The performance is competitive with glibc, although glibc
once again wins for very long strings, like due to the use
of AVX and/or AVX-512. It may be worth adding an AVX or
AVX-512 implementation of this function to trigger for
longer buffers only.

Sponsored by: The FreeBSD Foundation

Test Plan

passes test suite

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable