Date: Mon, 9 Jan 2012 23:27:28 +0100 From: Giovanni Trematerra <gianni@freebsd.org> To: Bruce Evans <brde@optusnet.com.au> Cc: jilles@freebsd.org, Attilio Rao <attilio@freebsd.org>, flo@freebsd.org, Konstantin Belousov <kib@freebsd.org>, freebsd-arch@freebsd.org Subject: Re: pipe/fifo code merged. Message-ID: <CACfq09225iMYLe6p8jSiVhsDw_rqTyEHsvPdtZXLrQYT0-skzg@mail.gmail.com> In-Reply-To: <20120110005155.S2378@besplex.bde.org> References: <CACfq093o9iVZKxCj58OR2hpCLDYTUTdxg_re_bEMYn2SrNrLCQ@mail.gmail.com> <20120110005155.S2378@besplex.bde.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Jan 9, 2012 at 3:34 PM, Bruce Evans <brde@optusnet.com.au> wrote: > On Sun, 8 Jan 2012, Giovanni Trematerra wrote: > >> Hi, >> the patch at >> http://www.trematerra.net/patches/pipefifo_merge2.diff >> >> is a preliminary version of the FIFO optimizations project that I picked >> up from >> the wiki. >> http://wiki.freebsd.org/IdeasPage#FIFO_optimizations_.28GSoC.29 > > > I would go the other way, and pessimize pipes to be like fifos. =A0Then > optimize the socket layer under both. =A0Fifos are not important, but > they are implemented on top of the socket layer which is important. > Pipes are important. =A0In 4.4BSD, pipes were implemented on top of the > socket layer too. =A0This was much simpler than for fifos -- pipe() was > just a wrapper that took a whole 44 lines, while fifofs took 602 lines. > Now, fifofs still only takes 753 lines, but sys_pipe.c takes 1671 > lines. =A0pipe() is similar to socketpair(), but even simpler. =A0socketp= air() > took 62 lines in 4.4BSD. =A0It still takes only 81 lines (the extras are > mainly for splitting it into sys_socketpair() and kern_socketpair()). > The pipe optimizations in FreeBSD originated in 1996. =A0They are good > locally, but may have inhibited more useful optimizations in the socket > layer. > [skip] > > The socket layer provides some fancy ioctls that might be useful and > even work for anything implemented on top of sockets. =A0The ones for > controlling socket buffer sizes and watermarks are most interesting. > I don't know if the fifo wrapper does anything to prevent passing these > to the socket layer. =A0For pipes, there are no fancy ioctls. =A0The pipe > code uses heuristics and thre hard-coded value PIPE_MINDIRECT to > decide whether it should try to optimize for small writes or large > writes. =A0These mostly work, but don't provide as much control as the > socket ioctls. =A0I once did a lot of benchmarking of FreeBSD pipe i/o > vs Linux pipe i/o. =A0Linux is much faster for small blocks and FreeBSD > is much faster for large blocks provided they are not so large as to > bust caches. =A0This is because although the FreeBSD options for direct > writes work, they have large overheads, and FreeBSD has much larger > overheads generally. =A0If the application could control the mode, then > the overheads could be reduced by switching to completely different > code (and if you want socket ioctls, even to the socket code). =A0But > this would be very complicated. Thanks a lot for your time. I see you don't like the way pipes are implemented in FreeBSD but that isn't relevant with the patch. The aim of the patch is eliminating unnecessary code, introduce no performance penalty into pipe code and make fifos faster. I think the patch achieved all the above goals. If we have to implement pipes on top of the socket layer or in a different way is just a different story. if we'll come up with a better implementation for the pipes, with this patc= h, fifos gain the improvements for free. > > Linux-2.6.10 implements fifos as a small wrapper around pipes, while > FreeBSD implements them as a large wrapper around sockets. =A0I hope the > former is what you do -- share most pipe code, without making it more > complicated, and with making the fifo wrapper much simpler. =A0The Linux > code is much simpler and smaller, since for pipes it it doesn't > implement direct mode, and for sockets it doesn't have to interact with > the complicated socket layer. If you read the patch, as I think you didn't, you'd see that there's no wra= pper at all. fifo's code is just fifo_open, fifo_close and another couple of hel= per functions to deal with VFS, all the remaining code is shared with pipes and no complicated code was added. -- Gianni
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CACfq09225iMYLe6p8jSiVhsDw_rqTyEHsvPdtZXLrQYT0-skzg>