Subject: Re: Faster pipes from FreeBSD
To: Artur Grabowski <art@openbsd.org>
From: Jaromír <jdolecek@netbsd.org>
List: tech-kern
Date: 04/07/2001 18:33:00
Artur Grabowski wrote:
> There is no real solution to this. Preallocating in sys_pipe will waste
> a lot of memory and failing allocation on demand will cause write(2) on pipes

I believe the right thing here is to allocate the necessary memory
space in pipe(2) and later only reallocate if needed for bigpipes
(if possible to do so).  Note the memory is not wired, so no physical
memory is wasted, "just" kernel virtual memory space.  Typically,
the unnecessary write end would be closed before any data is written
to the buffer, so immediate allocation should have close to zero
performance impact. In this case, I prefer correctness to couple
of saved {nano|micro}seconds - I think it's appropriate to return such error
from pipe(2), but not from write(2). And a panic() there is highly
inappropriate. I don't want to create trivial ways to panic
a NetBSD machine.

I'll modify the implementation to do this; the necessary changes
are quite trivial.

Also, it seems like modifying the code to use uvm_loan() for
big enough chunks should not be TOO hard. I'll try to play with
this. I expect saving one memory copy might help quite a lot
for "big" chunks (and machines with slow memory, like my 386DX PS/2 :)

Jaromir
-- 
Jaromir Dolecek <jdolecek@NetBSD.org>      http://www.ics.muni.cz/~dolecek/
NetBSD - just plain best OS! -=<>=- Got spare MCA cards or docs? Hand me them!