Coalescing pipe allocation

Dan Nelson dnelson at allantgroup.com
Tue Feb 3 10:56:15 PST 2004


In the last episode (Feb 03), Dag-Erling Smorgrav said:
> Robert Watson <rwatson at FreeBSD.org> writes:
> > Well, I don't know so much about the portability issues, but I can
> > say that it seems silly to incur the costs if few applications take
> > advantage of the feature.  Especially if the cost can be defered
> > until the feature is exercised.  I have some local patches that
> > defer all pipe buffer allocation until a particular direction is
> > first used, but this has some potential downsides, including
> > increasing the chances that a lack of resources is discovered on
> > first-use, rather than on allocation of the pipe (which makes it a
> > lot harder to write robust applications).
> 
> This is IMHO a lesser evil than the current behaviour, and there is
> always the option of blocking if memory can't be allocated right away.

How about always allocating at least enough for one direction (since I
don't think many people just call pipe() to use up fds), and deferring
allocation of the other direction until it's used?  I'm assuming it's
easy to swap the buffers around if you allocate the 0->1 direction but
for some reason the program decides to use the 1->0 one instead.  That
should cover the usual case.

-- 
	Dan Nelson
	dnelson at allantgroup.com


More information about the freebsd-current mailing list