in reply to Re: BitStream revisited
in thread BitStream revisited
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: BitStream revisited
by tachyon (Chancellor) on Dec 31, 2003 at 05:11 UTC |