From owner-freebsd-hackers@freebsd.org Thu Jan 7 16:30:47 2016 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4E19FA67D28 for ; Thu, 7 Jan 2016 16:30:47 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay02.stack.nl [IPv6:2001:610:1108:5010::104]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client CN "mailhost.stack.nl", Issuer "CA Cert Signing Authority" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 1B9F91556 for ; Thu, 7 Jan 2016 16:30:46 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id 1F2A5358C67; Thu, 7 Jan 2016 17:30:42 +0100 (CET) Received: by snail.stack.nl (Postfix, from userid 1677) id CE02D28494; Thu, 7 Jan 2016 17:30:41 +0100 (CET) Date: Thu, 7 Jan 2016 17:30:41 +0100 From: Jilles Tjoelker To: Malcolm Matalka Cc: freebsd-hackers@freebsd.org Subject: Re: Can PIPE_BUF be increased? Message-ID: <20160107163041.GA35588@stack.nl> References: <86ziwho1jg.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Jan 2016 16:30:47 -0000 On Thu, Jan 07, 2016 at 04:27:56PM +0100, Malcolm Matalka wrote: > Den 7 jan 2016 4:24 em skrev "Malcolm Matalka" : > > As far as I can tell, PIPE_BUF is 512 bytes by default. Using > > getconf and looking at the header files /usr/include. I'm writing a > > program that would benefit from a larger PIPE_BUF, is it possible to > > change this value? It looks like Linux and OS X have a higher > > default and OS X will do some magic to increase the size if > > necessary. I haven't found anything indicating the same in FreeBSD. > I realized I might not be clear enough here: I'm trying to increase > the number if bytes i can write to a pipe atomically. An active pipe buffer is always at least 4096 bytes, so this value can be increased somewhat without increasing memory usage. Going all the way to 4096 is probably unwise since it may require -- in low memory situations -- the buffer to be emptied completely before select/poll/kqueue report the pipe as writable again. You will need to recompile the kernel and filesystem and ABI compatibility modules after making the change in sys/sys/syslimits.h. FreeBSD automatically resizes pipe buffers and copies large (>= 8192 bytes) blocking writes directly from sender to receiver, but this does not provide atomicity guarantees. -- Jilles Tjoelker