This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Make the buffer size for the perlio layer a macro.
authorCraig A. Berry <craigberry@mac.com>
Wed, 10 Nov 2010 02:20:12 +0000 (20:20 -0600)
committerCraig A. Berry <craigberry@mac.com>
Wed, 10 Nov 2010 04:09:42 +0000 (22:09 -0600)
The 4K buffer size was chosen way back in bb9950b.  Significant performance
improvements are seen with larger buffer sizes, though the optimum size
likely varies by architecture and workload.  For starters, we'll leave the
default as-is but make the buffer size a macro and thus user-configurable via:

  sh Configure -Accflags=-DPERLIO_BUFSIZ=<number>

Choosing a better (larger) default is still TODO.

perlio.c
perlio.h

index 4073c97..5b39679 100644 (file)
--- a/perlio.c
+++ b/perlio.c
@@ -4120,7 +4120,7 @@ PerlIOBuf_get_base(pTHX_ PerlIO *f)
 
     if (!b->buf) {
        if (!b->bufsiz)
-           b->bufsiz = 4096;
+           b->bufsiz = PERLIO_BUFSIZ;
        Newxz(b->buf,b->bufsiz, STDCHAR);
        if (!b->buf) {
            b->buf = (STDCHAR *) & b->oneword;
index a6902d4..a1436c6 100644 (file)
--- a/perlio.h
+++ b/perlio.h
@@ -189,6 +189,10 @@ PERL_EXPORT_C void PerlIO_clone(pTHX_ PerlInterpreter *proto,
 #define BUFSIZ 1024
 #endif
 
+#ifndef PERLIO_BUFSIZ
+#define PERLIO_BUFSIZ 4096
+#endif
+
 #ifndef SEEK_SET
 #define SEEK_SET 0
 #endif