From owner-svn-src-all@FreeBSD.ORG Wed Aug 18 21:02:38 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4CF6B1065696; Wed, 18 Aug 2010 21:02:38 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from server.mypc.hu (server.mypc.hu [87.229.73.95]) by mx1.freebsd.org (Postfix) with ESMTP id 0301C8FC17; Wed, 18 Aug 2010 21:02:37 +0000 (UTC) Received: from server.mypc.hu (localhost [127.0.0.1]) by server.mypc.hu (Postfix) with ESMTP id 3C19E14DC6E8; Wed, 18 Aug 2010 23:02:37 +0200 (CEST) X-Virus-Scanned: amavisd-new at server.mypc.hu Received: from server.mypc.hu ([127.0.0.1]) by server.mypc.hu (server.mypc.hu [127.0.0.1]) (amavisd-new, port 10024) with LMTP id umeqWp3ykYvU; Wed, 18 Aug 2010 23:02:34 +0200 (CEST) Received: from [192.168.1.105] (catv-80-99-92-167.catv.broadband.hu [80.99.92.167]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by server.mypc.hu (Postfix) with ESMTPSA id 924E314DC315; Wed, 18 Aug 2010 23:02:34 +0200 (CEST) Message-ID: <4C6C4A67.4000002@FreeBSD.org> Date: Wed, 18 Aug 2010 23:02:31 +0200 From: Gabor Kovesdan User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; pt-PT; rv:1.9.2.8) Gecko/20100802 Thunderbird/3.1.2 MIME-Version: 1.0 To: mdf@FreeBSD.org References: <201008181740.o7IHeA4c075984@svn.freebsd.org> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r211463 - head/usr.bin/grep X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Aug 2010 21:02:38 -0000 Em 2010.08.18. 22:48, mdf@FreeBSD.org escreveu: > On Wed, Aug 18, 2010 at 10:40 AM, Gabor Kovesdan wrote: >> Author: gabor >> Date: Wed Aug 18 17:40:10 2010 >> New Revision: 211463 >> URL: http://svn.freebsd.org/changeset/base/211463 >> >> Log: >> - Refactor file reading code to use pure syscalls and an internal buffer >> instead of stdio. This gives BSD grep a very big performance boost, >> its speed is now almost comparable to GNU grep. > I didn't read all of the details in the profiling mails in the thread, > but does this mean that work on stdio would give a performance boost > to many apps? Or is there something specific about how grep(1) is > using its input that makes it a horse of a different color? In stdio, there is some overhead of FILE * locking but in first phase we reduced that overhead by locking once after opening and releasing the lock once before closing (it's fine given that grep isn't threaded). In the previous code, grep read data by character (calling fgetc_unlocked) and now it reads in bigger chunks, this is another difference, which may have improved the performance. We haven't checked using stdio in chunks, because dealing directly with file descriptors made it easier to handle gzip/bzip2 files, so after having seen that the old solution was wrong, this idea came directly. So I cannot surely answer the question. It would be an interesting task to run a benchmark on this, though. Gabor