[RFC] Improve wordexp performance.
Ondřej Bílka
neleai@seznam.cz
Wed May 13 18:36:00 GMT 2015
On Wed, May 13, 2015 at 01:32:00PM -0400, Carlos O'Donell wrote:
> On 05/13/2015 08:49 AM, OndÅej BÃlka wrote:
> > Hi, as I read Paul's wordexp patch I found that you use inefficient
> > idiom. Checking character membership with strchr is slow due to startup
> > cost. Much better is just use table lookup.
>
> How did you test it was faster?
>
You don't need to look at barometer to see if its raining. It does
single memory access which takes around 5-6 cycles is faster than strchr that takes ~30 cycles
and cannot be faster as it also needs to do a memory access.
> Could you please add a wordexp microbenchmark to show the gains?
>
I could. Its easy to make microbenchmark that shows improved performance.
Also its easy to make microbenchmark that makes it a regression. Just
use 128 byte IFS env. variable and call wordexp("x", foo, 0)
I could also make microbenchmark that is inconclusive as performance
difference is lost in syscall overhead of finding filenames by glob.
So I wont make microbenchmark as it would be useless exercise for pretty
obvious case.
You would need runtime profiling to get something useful.
More information about the Libc-alpha
mailing list