From owner-freebsd-current@FreeBSD.ORG Mon Aug 23 17:52:26 2010 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 01A39106566B; Mon, 23 Aug 2010 17:52:26 +0000 (UTC) (envelope-from alc@cs.rice.edu) Received: from mail.cs.rice.edu (mail.cs.rice.edu [128.42.1.31]) by mx1.freebsd.org (Postfix) with ESMTP id C6CB78FC26; Mon, 23 Aug 2010 17:52:25 +0000 (UTC) Received: from mail.cs.rice.edu (localhost.localdomain [127.0.0.1]) by mail.cs.rice.edu (Postfix) with ESMTP id B20732C2A91; Mon, 23 Aug 2010 12:52:17 -0500 (CDT) X-Virus-Scanned: by amavis-2.4.0 at mail.cs.rice.edu Received: from mail.cs.rice.edu ([127.0.0.1]) by mail.cs.rice.edu (mail.cs.rice.edu [127.0.0.1]) (amavisd-new, port 10024) with LMTP id t13j4dvwm1Mt; Mon, 23 Aug 2010 12:52:09 -0500 (CDT) Received: from adsl-216-63-78-18.dsl.hstntx.swbell.net (adsl-216-63-78-18.dsl.hstntx.swbell.net [216.63.78.18]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.cs.rice.edu (Postfix) with ESMTP id 85CD92C2A8C; Mon, 23 Aug 2010 12:52:09 -0500 (CDT) Message-ID: <4C72B550.2000001@cs.rice.edu> Date: Mon, 23 Aug 2010 12:52:16 -0500 From: Alan Cox User-Agent: Thunderbird 2.0.0.24 (X11/20100725) MIME-Version: 1.0 To: =?UTF-8?B?RGFnLUVybGluZyBTbcO4cmdyYXY=?= 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> <8639ufd78w.fsf@ds4.des.no> <4C6844D8.5070602@andric.com> <86sk2faqdl.fsf@ds4.des.no> <4C6AAA88.5080606@andric.com> <4C6AF13A.1080606@andric.com> <4C6D3BBB.7030104@andric.com> <4C6D5302.4030602@cs.rice.edu> <8639u9f5jj.fsf@ds4.des.no> In-Reply-To: <8639u9f5jj.fsf@ds4.des.no> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Cc: alc@freebsd.org, Dimitry Andric , current@freebsd.org Subject: Re: Official request: Please make GNU grep the default X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2010 17:52:26 -0000 Dag-Erling Smørgrav wrote: > Alan Cox 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