HomeFreeBSD

Reimplement strlen

Description

Reimplement strlen

The previous code neglected to use primitives which can find the end
of the string without having to branch on every character.

While here augment the somewhat misleading commentary -- strlen as
implemented here leaves performance on the table, especially so for
userspace. Every arch should get a dedicated variant instead.

In the meantime this commit lessens the problem.

Tested with glibc test suite.

Naive test just calling strlen in a loop on Haswell (ops/s):

$(perl -e "print 'A' x 3"):
before: 211198039
after: 338626619

$(perl -e "print 'A' x 100"):
before: 83151997
after: 98285919

(cherry picked from commit 710e45c4b8539d028877769f1a4ec088c48fb5f1)

Details

Provenance
mjgAuthored on Jan 29 2021, 9:48 PM
Parents
rG2bf72739da6f: poll: use fget_unlocked or fget_only_user when feasible
Branches
Unknown
Tags
Unknown