Page MenuHomeFreeBSD

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

Authored by emaste on Oct 20 2018, 10:26 PM.

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
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; 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)