Strange performance issue with grep -r -i as non-root user

Gary Palmer gpalmer at freebsd.org
Sun Mar 6 02:46:07 UTC 2011


On Sat, Mar 05, 2011 at 03:45:14PM -0800, Jeremy Chadwick wrote:
> This is a strange one, and the more I started debugging it (starting
> with truss, comparing fast vs. slow results, where all that appears
> different is read() operations are taking a lot longer -- I haven't had
> time to check with ktrace yet), the more strange it got: that's when I
> found out the behaviour changes depending on if you're a user or root.
> 
> Easy to reproduce:
> 
> - grep -r string /usr/src, as non-root, is fast
> - grep -r -i string /usr/src, as non-root, is 8x slower than without -i
> - grep -r string /usr/src, as root, is fast
> - grep -r -i string /usr/src, as root, is fast

This is a stab in the dark, but are there any differences in your
shell environment variables between root and non-root?  Specifically
LANG or LC_ style variables.  I ran into issues in the past with grep
being horrendously slow and traced it to LANG or LC_* in the environment
causing a much longer code path than without the settings.

Regards,

Gary



More information about the freebsd-stable mailing list