Date: Mon, 20 Oct 2008 16:13:25 +0200 From: Mel <fbsd.hackers@rachie.is-a-geek.net> To: freebsd-hackers@freebsd.org Cc: Dan Nelson <dnelson@allantgroup.com>, Ivan Voras <ivoras@freebsd.org> Subject: Re: Pipes, cat buffer size Message-ID: <200810201613.25864.fbsd.hackers@rachie.is-a-geek.net> In-Reply-To: <20081019005021.GN99270@dan.emsphone.com> References: <gddjoj$apg$1@ger.gmane.org> <9bbcef730810181719x4387a14yec74bdb6893d1a2a@mail.gmail.com> <20081019005021.GN99270@dan.emsphone.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200810201613.25864.fbsd.hackers>