develooper Front page | perl.perl5.porters | Postings from September 2012

Re: [perl #24067] IO::Handle::error doesn't report errors

Thread Previous | Thread Next
Aaron Crane
September 30, 2012 06:13
Re: [perl #24067] IO::Handle::error doesn't report errors
Message ID:
James E Keenan via RT <> wrote:
> On Sat Oct 18 04:58:34 2003, davem wrote:
>> On Mon, Sep 29, 2003 at 03:43:41PM -0000, (via
>> RT) wrote:
>> > The following perl program writes 4096 bytes to a file, checking for errors:
> Reviewing this older ticket this evening, I could reproduce the OP's
> results with Perl 5.12 on Linux/i386:
> However, on 5.14 and 5.16, I don't get the print failure message, even
> though I still get the "errors: no":
> Does anyone know what has changed, for better or worse?

I can reproduce the OP's results under 5.16 by increasing the constant
4096 to 8192.  I believe that's because of this commit that first went
into 5.14:

commit b83080de5c42543809ce9004bcdbcd3162a00e70
Author: Craig A. Berry <>
Date:   Thu Feb 17 14:24:39 2011 -0600

    Increase PERLIOBUF_DEFAULT_BUFSIZ to larger of 8192 and BUFSIZ.

    The previous default size of a PerlIO buffer (4096 bytes) was
    chosen many years ago before PerlIO was even the default I/O scheme
    for Perl.  Benchmarks show that doubling this decade-old default
    increases read and write performance in the neighborhood of 25%
    to 50% when using the default layers of perlio on top of unix.

    The only situation without a noticeable performance benefit so
    far appears to be when physical I/O is so slow that it dwarfs
    any savings from the reduction in layer shuffling, but there
    is also no performance penalty in this case.

    BUFSIZ will be chosen in the unlikely event that it's larger
    than 8192 on the assumption that the system maintainers would
    not set such a value without good reason.

    If the new size causes problems, or to try an even bigger size,
    configure with:

      ./Configure -Accflags=-DPERLIOBUF_DEFAULT_BUFSIZ=N

    where N is the desired size in bytes; it should probably be a
    multiple of your page size.

That is, when the amount of data written is less than the buffer size,
no OS-level write() call gets issued because of the Perl print.  So
the increase in Perl's default buffer size means that a larger print
is needed to trigger this behaviour.

But it does look like a bug to me that $fh->error returns false after
$fh->print has failed.

Aaron Crane **

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About