From owner-freebsd-hackers@FreeBSD.ORG Mon Oct 20 14:13:28 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0549A1065674 for ; Mon, 20 Oct 2008 14:13:28 +0000 (UTC) (envelope-from fbsd.hackers@rachie.is-a-geek.net) Received: from mail.rachie.is-a-geek.net (rachie.is-a-geek.net [66.230.99.27]) by mx1.freebsd.org (Postfix) with ESMTP id C4C888FC1F for ; Mon, 20 Oct 2008 14:13:27 +0000 (UTC) (envelope-from fbsd.hackers@rachie.is-a-geek.net) Received: from localhost (mail.rachie.is-a-geek.net [192.168.2.101]) by mail.rachie.is-a-geek.net (Postfix) with ESMTP id DEB3BAFBC01; Mon, 20 Oct 2008 06:13:26 -0800 (AKDT) From: Mel To: freebsd-hackers@freebsd.org Date: Mon, 20 Oct 2008 16:13:25 +0200 User-Agent: KMail/1.9.7 References: <9bbcef730810181719x4387a14yec74bdb6893d1a2a@mail.gmail.com> <20081019005021.GN99270@dan.emsphone.com> In-Reply-To: <20081019005021.GN99270@dan.emsphone.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200810201613.25864.fbsd.hackers@rachie.is-a-geek.net> Cc: Dan Nelson , Ivan Voras Subject: Re: Pipes, cat buffer size X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Oct 2008 14:13:28 -0000 On Sunday 19 October 2008 02:50:22 Dan Nelson wrote: > > But if it works in general, it may simply be that it isn't really > > applicable to my purpose (and I should modify the reader to read > > multiple blocks). > > That's my suggestion, yes. That way your program would also work when > passed data from an internet socket (where you will get varying read() > sizes too). It wouldn't add more than 10 lines to wrap your read in a > loop that exits when your preferred size has been reached. Since you mention a socket, would this patch be a good idea and use kqueue to read from the pipe? I would think that having the kernel fill the buffer, rather then a busy loop kernel/userland would improve speed, but I'm not too familiar with the code to know if this causes any problems. diff -u -r1.191.2.3 sys_pipe.c --- sys_pipe.c 6 Jun 2008 12:17:28 -0000 1.191.2.3 +++ sys_pipe.c 20 Oct 2008 14:04:18 -0000 @@ -1594,7 +1609,10 @@ PIPE_UNLOCK(rpipe); return (1); } - ret = kn->kn_data > 0; + if ( kn->kn_sfflags & NOTE_LOWAT) + ret = kn->kn_data >= kn->kn_sdata; + else + ret = kn->kn_data > 0; PIPE_UNLOCK(rpipe); return ret; } -- Mel