Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 23 Aug 2010 12:52:16 -0500
From:      Alan Cox <alc@cs.rice.edu>
To:        =?UTF-8?B?RGFnLUVybGluZyBTbcO4cmdyYXY=?= <des@des.no>
Cc:        alc@freebsd.org, Dimitry Andric <dimitry@andric.com>, current@freebsd.org
Subject:   Re: Official request: Please make GNU grep the default
Message-ID:  <4C72B550.2000001@cs.rice.edu>
In-Reply-To: <8639u9f5jj.fsf@ds4.des.no>
References:  <4C6505A4.9060203@FreeBSD.org>	<20100813085235.GA16268@freebsd.org> <4C66C010.3040308@FreeBSD.org>	<4C673F02.8000805@FreeBSD.org>	<20100815013438.GA8958@troutmask.apl.washington.edu>	<4C67492C.5020206@FreeBSD.org>	<B7A05068-9578-4341-851B-86BD9BC7A2DA@gmail.com>	<8639ufd78w.fsf@ds4.des.no> <4C6844D8.5070602@andric.com>	<86sk2faqdl.fsf@ds4.des.no> <4C6AAA88.5080606@andric.com>	<AANLkTik-ee6iKiOoA=KMmmToS2giUOmW5JB-d1vBx9r3@mail.gmail.com>	<4C6AF13A.1080606@andric.com>	<AANLkTikCyVVmx3-f4g2x1a%2Bq6PYOCLA-KrF53NFTx7uQ@mail.gmail.com>	<4C6D3BBB.7030104@andric.com> <4C6D5302.4030602@cs.rice.edu> <8639u9f5jj.fsf@ds4.des.no>

next in thread | previous in thread | raw e-mail | index | archive | help
Dag-Erling Smørgrav wrote:
> Alan Cox <alc@cs.rice.edu> writes:
>   
>> Here is what actually puzzles me about these results.  With
>> traditional I/O, even after the optimizations to bsdgrep, the system
>> time for gnugrep is still less than half that of the optimized
>> bsdgrep.  I haven't looked at the changes, but I would have thought
>> the system time for gnugrep and bsdgrep would be almost the same.
>>     
>
> Two reasons:
>
> 1) BSD grep does tons of unnecessary memory-to-memory copy operations in
>    grep_fgetln().
>
> 2) GNU grep has its own highly optimized regex code.
>
>   

Umm, not really.  Notice that I said "system time" not "user time".  
Even after the recent changes to optimize the I/O in bsdgrep, Dimitry's 
results show that bsdgrep is spending more than twice as much time in 
the kernel as gnugrep.  That said, in the end, you may be right in the 
sense that the user space inefficiencies may indirectly result in more 
cache misses in the kernel because the additional user space memory used 
by bsdgrep displaces more kernel data from the cache between system 
calls.  However, I would not jump to that conclusion.  The explanation 
for the difference in system time may be more straightforward and easy 
to fix.

It would be nice to see a comparison of bsdgrep and gnugrep using 
pmcstat to profile L2 cache misses.  That might be enlightening.

Alan




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4C72B550.2000001>