Piping into two processes simultaneously

Leslie Mikesell les at chinet.chi.il.us
Thu Sep 13 05:15:01 AEST 1990


In article <20005:Sep1114:10:2290 at kramden.acf.nyu.edu> brnstnd at kramden.acf.nyu.edu (Dan Bernstein) writes:

>It's axiomatic that you lose turnaround time when your slowest process
>is forced to block. (The weakest link...) Say you have data flowing from
>A into B into C into F, and from A into D into E into F. Say B and E are
>the bottlenecks. Now if we use your tee-based solution for the A-B-D
>split, then D will block as soon as B does. E won't get all its data
>until B is basically done. So you've pretty much doubled your turnaround
>time.

>Now do you understand the problem?

I understand the situation, but I don't see why it should be a problem
unless the producer is interactive with the faster of the two consumers.
Otherwise you're not done till you're all done, and you might as well
pace the output to the slowest consumer.

>multitee notices when an output blocks and sends the data to the other
>outputs. It can in theory be configured to buffer up to the memory size,
>but with any buffer it has a much lower chance than tee of being the
>bottleneck in a pipeline.

But pipes buffer all by themselves, up to PIPE_BUF anyway so the
processes don't have to sync down to the read/write level.  I don't
see the gain from any additional buffering except in the odd situation
noted above.  Most programs are going to use block buffered stdio going
into the pipe in the first place which is good for efficiency but not
for interactive type things.

Les Mikesell
  les at chinet.chi.il.us



More information about the Comp.unix.questions mailing list