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
F106785715: D17630.id49370.diff
Sun, Jan 5, 9:33 AM
Unknown Object (File)
Nov 17 2024, 11:18 AM
Unknown Object (File)
Oct 14 2024, 5:14 PM
Unknown Object (File)
Oct 14 2024, 5:14 PM
Unknown Object (File)
Oct 14 2024, 5:14 PM
Unknown Object (File)
Oct 14 2024, 4:43 PM
Unknown Object (File)
Oct 1 2024, 3:12 PM
Unknown Object (File)
Sep 27 2024, 10:58 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)