Skip to content

Commit

Permalink
Increase PERLIOBUF_DEFAULT_BUFSIZ to larger of 8192 and BUFSIZ.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
craigberry committed Feb 17, 2011
1 parent c22d665 commit b83080d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion perlio.h
Expand Up @@ -191,7 +191,7 @@ PERL_EXPORT_C void PerlIO_clone(pTHX_ PerlInterpreter *proto,

/* The default buffer size for the perlio buffering layer */
#ifndef PERLIOBUF_DEFAULT_BUFSIZ
#define PERLIOBUF_DEFAULT_BUFSIZ 4096
#define PERLIOBUF_DEFAULT_BUFSIZ (BUFSIZ > 8192 ? BUFSIZ : 8192)
#endif

#ifndef SEEK_SET
Expand Down

0 comments on commit b83080d

Please sign in to comment.