Anonymous Vs Named Pipes

Anonymous Vs Named Pipes

am 04.12.2007 18:44:27 von tom

I haven't been able to track down a definitive answer on this, so I'm
hoping someone in this group may know the answer.

Does an anonymous pipe have any benefits over a named pipe? Does a
named pipe physically write to the filesystem that pipe resides in
(thus the speed of the write is dependant on the speed of the disk).
The reason I'm curious is if I know I have an IO bottleneck, will
using named pipes cause me to feel that bottleneck, or is it all in
memory like an anonymous pipe.

ie)
cat test.dat | grep junk 1>/dev/null
vs
mkfifo test.dat.pipe
cat test.dat > test.dat.pipe &
grep junk test.dat.pipe 1>/dev/null

Re: Anonymous Vs Named Pipes

am 04.12.2007 21:17:23 von Barry Margolin

In article
<292a8add-fa51-4d3d-84cc-323686c4cd92@l1g2000hsa.googlegroups.com>,
Tom wrote:

> I haven't been able to track down a definitive answer on this, so I'm
> hoping someone in this group may know the answer.
>
> Does an anonymous pipe have any benefits over a named pipe? Does a
> named pipe physically write to the filesystem that pipe resides in
> (thus the speed of the write is dependant on the speed of the disk).
> The reason I'm curious is if I know I have an IO bottleneck, will
> using named pipes cause me to feel that bottleneck, or is it all in
> memory like an anonymous pipe.
>
> ie)
> cat test.dat | grep junk 1>/dev/null
> vs
> mkfifo test.dat.pipe
> cat test.dat > test.dat.pipe &
> grep junk test.dat.pipe 1>/dev/null

The only difference between anonymous and named pipes is in how the
initial pipe connection is made. There's no difference during data
transfer. A named pipe is just a rendezvous mechanism, nothing is
written to the filesystem.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***

Re: Anonymous Vs Named Pipes

am 04.12.2007 21:46:38 von tom

On Dec 4, 2:17 pm, Barry Margolin wrote:
> In article
> <292a8add-fa51-4d3d-84cc-323686c4c...@l1g2000hsa.googlegroups.com>,
>
>
>
>
>
> Tom wrote:
> > I haven't been able to track down a definitive answer on this, so I'm
> > hoping someone in this group may know the answer.
>
> > Does an anonymous pipe have any benefits over a named pipe? Does a
> > named pipe physically write to the filesystem that pipe resides in
> > (thus the speed of the write is dependant on the speed of the disk).
> > The reason I'm curious is if I know I have an IO bottleneck, will
> > using named pipes cause me to feel that bottleneck, or is it all in
> > memory like an anonymous pipe.
>
> > ie)
> > cat test.dat | grep junk 1>/dev/null
> > vs
> > mkfifo test.dat.pipe
> > cat test.dat > test.dat.pipe &
> > grep junk test.dat.pipe 1>/dev/null
>
> The only difference between anonymous and named pipes is in how the
> initial pipe connection is made. There's no difference during data
> transfer. A named pipe is just a rendezvous mechanism, nothing is
> written to the filesystem.
>
> --
> Barry Margolin, bar...@alum.mit.edu
> Arlington, MA
> *** PLEASE post questions in newsgroups, not directly to me ***
> *** PLEASE don't copy me on replies, I'll read them in the group ***- Hide quoted text -
>
> - Show quoted text -

That's what my testing told me, but I was curious why an ls -l shows
filesizes on pipes. My guess is that's what's in memory for that
pipe, but again, couldn't find that spelled out anywhere.

Thanks Barry!

Re: Anonymous Vs Named Pipes

am 05.12.2007 04:12:13 von spcecdt

In article ,
Barry Margolin wrote:
>In article
><292a8add-fa51-4d3d-84cc-323686c4cd92@l1g2000hsa.googlegroups.com>,
> Tom wrote:
>
>> I haven't been able to track down a definitive answer on this, so I'm
>> hoping someone in this group may know the answer.
>>
>> Does an anonymous pipe have any benefits over a named pipe? Does a
>> named pipe physically write to the filesystem that pipe resides in
>> (thus the speed of the write is dependant on the speed of the disk).
>> The reason I'm curious is if I know I have an IO bottleneck, will
>> using named pipes cause me to feel that bottleneck, or is it all in
>> memory like an anonymous pipe.
>
>The only difference between anonymous and named pipes is in how the
>initial pipe connection is made. There's no difference during data
>transfer. A named pipe is just a rendezvous mechanism, nothing is
>written to the filesystem.

Not anymore - probably. But a classic method of implementing pipes (both named
and unnamed) in the days of expensive memory was to use inodes on a mounted
filesystem - typically the root filesystem - to keep track of the data, with
the block pointers all being used as direct pointers, and pipes actually using
blocks from the filesystem to store data, which might or might not ever be
written out. The number of block pointers & block size set the limit on the
amount of data that could be outstanding in a pipe. A bad shutdown would leave
the filesystem littered with orphaned allocated pipe inodes...

John
--
John DuBois spcecdt@armory.com KC6QKZ/AE http://www.armory.com/~spcecdt/

Re: Anonymous Vs Named Pipes

am 05.12.2007 05:40:01 von Barry Margolin

In article
<17bf6fe8-fece-4836-8d37-9301f4eb6dbd@w56g2000hsf.googlegroups.com>,
Tom wrote:

> On Dec 4, 2:17 pm, Barry Margolin wrote:
> > The only difference between anonymous and named pipes is in how the
> > initial pipe connection is made. There's no difference during data
> > transfer. A named pipe is just a rendezvous mechanism, nothing is
> > written to the filesystem.
>
> That's what my testing told me, but I was curious why an ls -l shows
> filesizes on pipes. My guess is that's what's in memory for that
> pipe, but again, couldn't find that spelled out anywhere.

The stat() system call, when invoked on a named pipe, extracts
information about the pipe from the kernel, not from the filesystem.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***