Subject: Re: Faster pipes from FreeBSD
To: Simon Burge <simonb@wasabisystems.com>
From: Artur Grabowski <art@openbsd.org>
List: tech-kern
Date: 04/06/2001 17:58:29
Simon Burge <simonb@wasabisystems.com> writes:

> "Jarom r" Dolecek wrote:
> 
> > I've made a stab at porting the FreeBSD sys_pipe() implementation to
> > NetBSD (that implementation was written by John S. Dyson). The
> > basics are finished, the thing works quite nicely and indeed about
> > 1.5-7x faster than out current pipes (wow!).
> 
> Cool!  My only comment so far is than a panic in pipespace() seems a bit
> extreme (and is a potential DoS attack?) - shouldn't sys_pipe just fail
> in this case if not more kvm can be allocated?

The problem here is that the pipes are bi-directional, but in almost all
cases only one side is used, so the pipe space is allocated on demand.

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
to fail in unexpected ways. Setting a limit on how much pipe memory can be
allocated and sleep when that limit has been reached will cause denial of
service situations (note that this can be triggered with socketpair).

> lmbench (and probably hbench) also include some pipe benchmarks (both
> bandwith and latency tests from memory) - you might want to check them
> out.

When I was writing a replacement for pipes that was using uvm_loan (I never
finished and I can't find the code anymore) I wrote a hort hack to test the
performance of my code. An older version is at ftp.blahonga.org:/pub/pipe.tar

//art