in reply to 4k read buffer is too small
AFAIK, stdio buffering - as configurable via setvbuf - is incompatible with PerlIO's buffering, which is why it's disabled when you configure Perl to use PerlIO. OTOH, you most probably do want PerlIO... so configuring/rebuilding Perl to not use it, isn't really an option.
Anyhow, a little digging around suggests that you can "configure" PerlIO's buffer size in the file perlio.c:
STDCHAR * PerlIOBuf_get_base(pTHX_ PerlIO *f) { PerlIOBuf * const b = PerlIOSelf(f, PerlIOBuf); PERL_UNUSED_CONTEXT; if (!b->buf) { if (!b->bufsiz) b->bufsiz = 4096; /* <--- here */ b->buf = Newxz(b->buf,b->bufsiz, STDCHAR); if (!b->buf) { b->buf = (STDCHAR *) & b->oneword; b->bufsiz = sizeof(b->oneword); } b->end = b->ptr = b->buf; } return b->buf; }
At least, I changed that 4096 to 8192, recompiled perl (v5.10.0), and now strace reveals that read(2) is being called for blocks of size 8192, when you execute something like
open my $fh, "<", $^X or die; while (<$fh>) { }
while before the change, read blocks were of size 4096.
Other than that, I haven't done any testing yet. So, no guarantees whatsoever (!) that it'll work in every respect... — just something to play with at your own risk. Good luck!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: 4k read buffer is too small
by voeckler (Sexton) on Jun 17, 2008 at 04:15 UTC | |
by almut (Canon) on Jun 17, 2008 at 15:06 UTC | |
by mr_mischief (Monsignor) on Jun 18, 2008 at 16:08 UTC | |
Re^2: 4k read buffer is too small
by DrHyde (Prior) on Jun 17, 2008 at 10:08 UTC | |
by Steve_p (Priest) on Jun 17, 2008 at 11:55 UTC | |
by voeckler (Sexton) on Jun 17, 2008 at 18:56 UTC |