Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!wuarchive!rice!katzo.rice.edu!zdenko From: zdenko@katzo.rice.edu (zdenko tomasic) Newsgroups: comp.unix.aix Subject: Re: run-time settting of PIPE_BUF Message-ID: <1991Jun14.200219.21922@rice.edu> Date: 14 Jun 91 20:02:19 GMT References: <1991Jun10.165521.10248@murdoch.acc.Virginia.EDU> <1991Jun10.185820.8120@rice.edu> <320@crcaus.cactus.org> Sender: news@rice.edu (News) Organization: Rice University Lines: 55 In article <320@crcaus.cactus.org> john@crcaus.UUCP (John R. Miller) writes: > > .... good points on PIPE_BUF ... > ... >If you are seeing too many context switches, I don't think it's caused ^^^^^^^^^^^^^^^^ >by pipe buffers filling up. Actually, I should mention that the whole thing started when I just let the shell set up the pipe for 2 user filters. The context switches were excessive (in millions) and the cpu time was way up just for the input part of the receiving end of the pipe (I did not measure the sending filter timing). After playing around with pipes set up explicitly through a C program and changing the pipe buffer sized with setbuffer (Chuck Karsh was kind to point that in his e-mail to me), I could push the number of context switches up by reducing the pipe buffer size. Since the pipe size buffer of less than 80 bytes roughly gives the number of context switches in the right ballpark, I conclude that the (csh,ksh) shells use line buffering for pipes, i.e. pipe buffers are then rather small --> too many context switches. I guess somebody assumed that stdin and stdout will allways involve terminal io and left everything line buffered at all times. The work-around is to make your own pipes and avoid shell pipes. I initially assumed (mislead by comments in the /usr/include/sys/limits.h) that 512 was the default PIPE_BUF and I am convinced now that it is not so (and even if it were it would not produce the observed number of context switches). I hope somebody could verify the above and change shell pipe buffering as other systems (e.g. MIPS) do not have such problems. There is no reason to make piping through shell as expensive as it is now, is there? > >disclaimer: I've been wrong before. me, too! > >-- >John R. Miller 13102 Briar Hollow Dr. Austin, Texas 78729 >hm: 512/331-0155 john@crcaus.cactus.org or ..cs.utexas.edu!bigtex!crcaus!john >wk: 512/823-3867 john@glasnost.austin.ibm.com -- ___________________________________________________________________ Zdenko Tomasic, Rice U., Chem. Dept., P.O. Box 1892, Houston, Tx 77251 INTERNET: zdenko@katzo.rice.edu ___________________________________________________________________