From owner-freebsd-current@FreeBSD.ORG Tue Aug 17 17:32:55 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 C54F01065672 for ; Tue, 17 Aug 2010 17:32:55 +0000 (UTC) (envelope-from alan.l.cox@gmail.com) Received: from mail-qw0-f54.google.com (mail-qw0-f54.google.com [209.85.216.54]) by mx1.freebsd.org (Postfix) with ESMTP id 702FE8FC23 for ; Tue, 17 Aug 2010 17:32:55 +0000 (UTC) Received: by qwg5 with SMTP id 5so7270095qwg.13 for ; Tue, 17 Aug 2010 10:32:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:reply-to :in-reply-to:references:date:message-id:subject:from:to:cc :content-type; bh=cXqxRi5Ftwm38qqFrPCHP5RCst/pYGgU7PW1B1Ur4F8=; b=gk60J6ZU9uQ8oqb5RK2omOu5jWnm2f7o3fBPywhn/PTVg7UsFvdKI2R/yqASoZnRRI Gf8+x5G47HNkZbCPH4faDFmprOYxlo7TUeb6iVdT5jUV1qPxlVL9M/K2oM+3WsMelZY4 jCeL1lOC7npjVs2zVQqB/JUy5AMFA03602bro= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:reply-to:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; b=x8PIGys4ne/BiBxOrIlxQfPoeHAMhGg8rzfj5NflUY1j86XxEIn2RakItHjh5JZCn2 6XIsEf+2jaSHM1QyzNyf09+UqTzc9tTZsz+dexewFLRk6L2y8Ypn6NJpD37zxOsAlwiN 0zUZI9oL3YqBkI3W4/p9HzzS5hcnnclPR/Y84= MIME-Version: 1.0 Received: by 10.224.71.148 with SMTP id h20mr4549759qaj.361.1282066372902; Tue, 17 Aug 2010 10:32:52 -0700 (PDT) Received: by 10.229.22.11 with HTTP; Tue, 17 Aug 2010 10:32:52 -0700 (PDT) In-Reply-To: <20100817154537.GM2396@deviant.kiev.zoral.com.ua> References: <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> <20100817154537.GM2396@deviant.kiev.zoral.com.ua> Date: Tue, 17 Aug 2010 12:32:52 -0500 Message-ID: From: Alan Cox To: Kostik Belousov Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: 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 Reply-To: alc@freebsd.org List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Aug 2010 17:32:55 -0000 On Tue, Aug 17, 2010 at 10:45 AM, Kostik Belousov wrote: > [Cc: list sanitized] > > On Tue, Aug 17, 2010 at 05:28:08PM +0200, Dimitry Andric wrote: > > On 2010-08-16 10:55, Dag-Erling Sm??rgrav wrote: > > > Dimitry Andric writes: > > >> - Uses plain file descriptors instead of struct FILE, since the > > >> buffering is done manually anyway, and it makes it easier to support > > >> gzip and bzip2. > > > It might be worth a shot adding mmap(2) support as well, i.e. when > > > processing an uncompressed regular file, try to mmap(2) it first, and > if > > > that fails, fall back to the plain buffered read(2) method. > > > > I added a simple mmap to grep, and time-trialed it, but the mmap version > > was somewhat slower than the regular version. I understood from Kostik > > Belousov that readahead does not work properly with mmap, and it should > > not be used for "one-time" reads. > This is not exactly what I said. I argue that read-ahead implemented > by vm_faul() is much less efficient that buffer clustering. Also, > the cost of setting user mapping for the one time read is also non-trivial. > The conclusion is right, it is better to use read(2) for one-time read. > The mapping (and unmapping) costs should be relatively small if the contents of the file can be prefaulted using 2/4MB pages. In such cases, we still touch every struct vm_page in the 2/4MB region, but we only create and destroy one PTE and PV entry, and perform a single INVLPG. Alan