how big is a pipe?

Doug Gwyn <gwyn> gwyn at brl-tgr.ARPA
Mon Oct 14 10:46:44 AEST 1985


> This may fall into the area of fuzzy thinking, but

Yes

> what's wrong with this arguement?

Everything

> To find out how big a pipe is, grab your handy manual and see how
> many pipes you can have open at one time.
> Remember that a pipe takes an inode so, this number
> times the size of your system's blocks should give the maximum
> capacity of a pipe. No?

(Assuming block I/O system pipes/FIFOs:)  There are several "sizes"
associated with pipes.  The maximum amount of unread data bufferable
in a pipe seems to be the one under consideration.  On older UNIXes,
this was 4096 bytes, and on newer UNIXes it is supposed to be 5120
bytes, according to the manual.  The simplest pipe implementation
uses only "direct blocks" named in the inode, for efficiency.  There
are typically 10 direct blocks in an inode, and the system blocksize
is usually 512 or 1024 bytes, or a "dual" 512/1024 system.

If you have a /usr/include/limits.h file, look in it to see what
PIPE_BUF and PIPE_MAX are defined as.

Why does anyone really care?  The size of an atomic write seems much
more important to me; this is a complicated issue that is affected
by O_NDELAY, the amount of unread data still in the pipe, etc.

Possibly interesting note:  I heard that someone measured pipe
throughput using both the block I/O inode ripoff scheme and
4.2BSD's socketpair scheme, and found that the traditional way
generally had higher throughput.



More information about the Comp.unix.wizards mailing list