Subject: Re: Faster pipes from FreeBSD
To: None <tech-kern@netbsd.org>
From: Greg A. Woods <woods@weird.com>
List: tech-kern
Date: 04/07/2001 00:01:05
[ On Friday, April 6, 2001 at 21:13:06 (-0400), Andrew Brown wrote: ]
> Subject: Re: Faster pipes from FreeBSD
>
> actually...while i know the strict "definition" of pipes is that they
> are unidirectional with a single read and a single write endpoint, in
> my (limited?) experience, i've always found pipes to be bidirectional.

Well, what you've probably looked at is only a very narrow range of
possible implementations, *or* a very modern range.  :-)

Certinaly the one canonical implementation that existed before half the
world became 4.2BSD based (or newer) was absolutely uni-directional.

I'm not exactly sure of the micro-details but I seem to remember that
some BSD implementations of pipes using unix-domain sockets were
purposefully crippled to be uni-directional.

My rather faded memory also suggests that even the original UNIX(tm)
pipes were one heck of a lot faster than the modern socketpair() hack
too.  That's even with their fixed (10 direct blocks, so usually 5KB)
size too!  Of course it's impossible to compare apples to apples in that
scenario, and even getting close by running on the same hardware is
"difficult".  IIRC since pipes were just anonymous inodes on the pipe
device their data blocks would be passed through the buffer cache and
thus would rarely be actually written to disk.

Of course then along came UNIX System V Release 4 where pipes were
implemented as STREAMS, and at least in some incarnations they were even
faster than the traditional ones, and they were bi-directional like
4.2BSD's uncrippled version, and they usually still have the 5KB buffer
limit.

> including ours.

The problem is that no programmer can ever write portable code that uses
bi-directional pipes without causing enormous nighmares for anyone
porting it to a "strictly conforming" implemenation that doesn't offer
bi-directional pipes.  The mere temptation has attracted enough abusers
already and made quite a lot of code far less portable than it really
needs to be (assuming there are still any uni-directional pipe
implementations still in use today).

That said I'd personally like to toss that particular restriction in
POSIX about as far as humanly possible.  It really should not be there
because it's not that terribly hard to implement bi-directional pipes.

Heck even the UNIX Research System grew bi-directional pipes *long* ago
(probably in 9'th Edition, and certainly by Tenth Edition, now over a
decade old).

-- 
							Greg A. Woods

+1 416 218-0098      VE3TCP      <gwoods@acm.org>     <woods@robohack.ca>
Planix, Inc. <woods@planix.com>;   Secrets of the Weird <woods@weird.com>