[PATCH] Optimize generic strtok(_r) function.
Wilco Dijkstra
Wilco.Dijkstra@arm.com
Thu Mar 12 17:40:16 GMT 2020
Hi Joseph,
In addition to Carlos' comments, I would like to add that it's best to split
your patch into several smaller, independent, changes. For example first
post patch series to update/improve the benchmarks for str(c)spn/strtok(_r).
Then post patches to improve strtok_r - and any similar optimizations
which could be applied to strspn and strcspn (it would be fine to inline
explictly but it seems best to keep using the same code layout and variable
names between the functions). Note I think you're losing some
optimizations, eg. for the case where the delimiter string is short.
I'm not so sure it's a good idea to add complex ifuncs to several targets -
we generally leave this to maintainers of those targets. If the new code
causes a major slowdown on some targets due to bypassing target
optimizations, then one option would be to add a define to keep
the existing generic strtok_r implementation so that the target overrides
for str(c)spn are still used.
It would be nice to clean up the various architecture implementations.
As Carlos mentioned, we aim to remove any assembler code which
doesn't improve performance. I believe that is the case for the i386,
x86_64 and sparc versions of strspn and strcspn as these are literally
assembler translations of the generic C code, and so wouldn't improve
performance.
Cheers,
Wilco
More information about the Libc-alpha
mailing list