Can PIPE_BUF be increased?
Malcolm Matalka
mmatalka at gmail.com
Thu Jan 7 17:09:43 UTC 2016
Jilles Tjoelker <jilles at stack.nl> writes:
> On Thu, Jan 07, 2016 at 04:27:56PM +0100, Malcolm Matalka wrote:
>> Den 7 jan 2016 4:24 em skrev "Malcolm Matalka" <mmatalka at gmail.com>:
>
>> > 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.
If I understand you correctly, I cannot do anything, with strong
guarantees, without recompiling the kernel?
Thank you for the answer!
/Malcolm
More information about the freebsd-hackers
mailing list