Unix Shell - Anonymous Vs Named Pipes

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > December 2007 > Anonymous Vs Named Pipes





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Anonymous Vs Named Pipes
Tom

2007-12-04, 1:25 pm

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
Barry Margolin

2007-12-04, 7:25 pm

In article
<292a8add-fa51-4d3d-84cc-323686c4cd92@l1g2000hsa.googlegroups.com>,
Tom <tomsellner@gmail.com> 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 ***
Tom

2007-12-04, 7:25 pm

On Dec 4, 2:17 pm, Barry Margolin <bar...@alum.mit.edu> wrote:
> In article
> <292a8add-fa51-4d3d-84cc-323686c4c...@l1g2000hsa.googlegroups.com>,
>
>
>
>
>
> Tom <tomsell...@gmail.com> 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.
>
> --
> 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!
John DuBois

2007-12-05, 1:42 am

In article <barmar-6D0D36.15172304122007@comcast.dca.giganews.com>,
Barry Margolin <barmar@alum.mit.edu> wrote:
>In article
><292a8add-fa51-4d3d-84cc-323686c4cd92@l1g2000hsa.googlegroups.com>,
> Tom <tomsellner@gmail.com> 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.


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/
Barry Margolin

2007-12-05, 1:42 am

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

> On Dec 4, 2:17 pm, Barry Margolin <bar...@alum.mit.edu> wrote:
>
> 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 ***
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com