You would play with the BLOCK_SIZE (probably 1-2MB will be optimal as a stab in the dark - see Re: Performance Question for details) to spend as much memory as you can/need to/is optimal and limit disk access.

There's actually only a marginal speedup for anything over the system block size, usually 4K or 8K. In fact, when the buffer size gets up to around a MB, things slow down a little bit.

All of these tests are with a warm cache on an approximately 1GB file.

#!/usr/bin/perl my $i = 0; while (sysread(STDIN,$buf,$ENV{BLOCKSIZE})) { $i++; } print "Called read $i times.\n";
$ BLOCKSIZE=4096 time perl /tmp/t6 <root_fs
Called read 262144 times.
0.55user 8.93system 0:38.36elapsed 24%CPU

$ BLOCKSIZE=8192 time perl /tmp/t6 <root_fs
Called read 131072 times.
0.47user 8.53system 0:39.10elapsed 23%CPU

$ BLOCKSIZE=16384 time perl /tmp/t6 <root_fs
Called read 65536 times.
0.24user 7.46system 0:38.04elapsed 20%CPU

$ BLOCKSIZE=65536 time perl /tmp/t6 <root_fs
Called read 16384 times.
0.17user 9.04system 0:38.16elapsed 24%CPU

$ BLOCKSIZE=262144 time perl /tmp/t6 <root_fs
Called read 4096 times.
0.13user 11.77system 0:38.53elapsed 30%CPU 

$ BLOCKSIZE=524288 time perl /tmp/t6 <root_fs
Called read 2048 times.
0.06user 12.49system 0:39.15elapsed 32%CPU 

$ BLOCKSIZE=1048576 time perl /tmp/t6 <root_fs
Called read 1024 times.
0.04user 12.94system 0:38.34elapsed 33%CPU

In reply to Re: Re: BitStream revisited by sgifford
in thread BitStream revisited by spurperl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.