Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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.
  • Loading branch information...
commit b83080de5c42543809ce9004bcdbcd3162a00e70 1 parent c22d665
@craigberry craigberry authored
Showing with 1 addition and 1 deletion.
  1. +1 −1  perlio.h
View
2  perlio.h
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.