[PATCH] libio: Always use _IO_BUFSIZE for stream buffers [BZ #4099]

Carlos O'Donell carlos@redhat.com
Mon Mar 14 19:31:00 GMT 2016


On 03/14/2016 07:08 AM, Florian Weimer wrote:
> On 03/11/2016 10:52 PM, Roland McGrath wrote:
>> Justify with clear rationale.
> 
> It fixes bug 4099.  We need an arbitrary limit for that.
> 
> The libstdc++ buffer size is 8192 (or 8191), so this makes buffering
> more consistent across the system.
> 
> The PostgreSQL people did extensive benchmarks to determine their
> block/page size, and settled for a 8192 (but they do not use stdio
> streams, for obvious reasons).
> 
> <stdio.h> documents BUFSIZ as the default buffer size. The new
> implementation matches that.
> 
> Additional memory consumption is limited because file descriptors are a
> scarce resource.
> 
> I can do some benchmarking, but I don't expect any compelling results.

I don't know that benchmarking is required, Roland just asked for clear
rationale.

However, it would be wonderful if you added a microbenchmark just to make
sure we don't actually cause any unforseen problems. This way people can
run such a benchmark again on their remote filesystems and give us results.

Your answer seems clear enough to me. I agree with it too. The advertised
st_blksize is useful only in the abstract. The runtime has to pick something
which works well with the current implementation as a whole.

The only objection I might see is that this is actually a Linux-specific
tuning that you've done. Nobody knows if this tuning has any impact on
Hurd or not.

I would consider this OK to checkin only if you provide a detailed comment
that talks about the tradeoffs being made here and why _IO_BUFSIZE was
chosen.

In summary:
- Add comment just above setting _IO_BUFSIZE about tradeoff [Required]
- Add microbenchmark to avoid surprises [Optional]

-- 
Cheers,
Carlos.



More information about the Libc-alpha mailing list