Page MenuHomeFreeBSD

libc: Use musl's optimized strchr, strchrnul, strcspn
ClosedPublic

Authored by emaste on Oct 20 2018, 10:26 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Apr 22, 1:26 AM
Unknown Object (File)
Wed, Apr 17, 5:34 PM
Unknown Object (File)
Sun, Apr 14, 7:54 PM
Unknown Object (File)
Mar 18 2024, 3:00 PM
Unknown Object (File)
Jan 12 2024, 2:47 AM
Unknown Object (File)
Dec 20 2023, 3:25 AM
Unknown Object (File)
Nov 27 2023, 8:29 PM
Unknown Object (File)
Nov 4 2023, 6:11 AM
Subscribers

Details

Summary

libc: Use musl's optimized strchr, strchrnul, strcspn

Parentheses added to HASZERO macro to avoid a GCC warning.

Obtained from: musl (snapshot at commit c648cefb)
Sponsored by: The FreeBSD Foundation

Diff Detail

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

Event Timeline

Looks fine from PoV of libc integration. I did not looked at the algorithms.

This revision is now accepted and ready to land.Oct 21 2018, 12:07 AM

Is this waiting on anything specific? By this point I woud only check for updates and get this in.

Looking over some old WIP I had strcspn in this review originally but did not commit it. Some benchmarking shows it's slower than existing libc for some cases I tried, so we can drop it. (Adding this comment for posterity.)

this is a strcspn(buf, " \t\n") where the match occurs after 64K:

x libc
+ musl
+------------------------------------------------------------------------------+
|          x x                                 +                               |
|         xx x                                 +                               |
|         xx x                                 + +                             |
|         xx x                                 + +                             |
|         xx x                                 + +                             |
|        xxxxx                                 + + +                           |
|        xxxxxx                                + + +                           |
|        xxxxxx                                +++ +                           |
|        xxxxxx                                +++ +                           |
|        xxxxxx                                +++++                           |
|        xxxxxx   x                  +       ++++++++                          |
|       xxxxxxx   xx                 +       ++++++++  +                       |
|       xxxxxxx x xx                 +       ++++++++  +                       |
|  x x  xxxxxxx x xx x x             +  + +  +++++++++ +                       |
|  x x  xxxxxxxxx xx x x             +  + +  +++++++++++       +               |
|  x xxxxxxxxxxxxxxxxx x          + +++++++ ++++++++++++       +               |
| xx xxxxxxxxxxxxxxxxx x  x  x    +++++++++ +++++++++++++++++  + +             |
| xx xxxxxxxxxxxxxxxxxxx  xxxx    ++++++++++++++++++++++++++++++ +             |
|xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx  +++*+++++*+++++++++++++++++++++++  + +       +|
|      |____M_A_____|                    |_______A______|                      |
+------------------------------------------------------------------------------+
    N           Min           Max        Median           Avg        Stddev
x 200         32752         46293         36478     36916.985     2172.4189
+ 200         43362         58179         48444     48463.315     2587.0197
Difference at 95.0% confidence
        11546.3 +/- 468.191
        31.2765% +/- 1.44552%
        (Student's t, pooled s = 2388.73)