Mail Archives: djgpp/2004/12/28/04:02:43
On Mon, 27 Dec 2004 10:25:29 +0200 in comp.os.msdos.djgpp, "Eli
Zaretskii" <eliz AT gnu DOT org> wrote:
>> From: Brian Inglis <Brian DOT Inglis AT SystematicSW DOT Invalid>
>> Date: Sun, 26 Dec 2004 22:13:39 GMT
>>
>> If you use setvbuf() *immediately after fopen()* to increase your
>> buffer size to 4/8/16KB, that technique may work even faster.
>
>Not with DJGPP. Since file I/O is done with DOS system calls, data is
>moved via the transfer buffer, whose size is 16KB by default.
>Consequently, any changes in buffer size via `setvbuf' will not yield
>any significant effect, except for ridiculously small arguments to
>`setvbuf', unless you also change the size of the transfer buffer (can
>be enlarged up to 65254 bytes).
>
>If memory serves, I once tried to play with `setvbuf' and transfer
>buffer changes to speed up I/O, but couldn't see any significant
>improvements. But you are welcome to try again and report the
>results.
Using setvbuf() with 32KB is *slightly* faster by about 1ms/10MB, and
16KB is *slightly* faster again by the same amount, than the default;
the fastest rate works out to about 4.6ms/MB or 217MB/s; doing
sequential reads on my machine and drive.
The default appears to be about equivalent to setvbuf() with 12KB,
doing sequential reads on my machine and drive.
I'd use the default unless I was reading lots of GB.
Sequential reads seem to be pretty well optimized!
>> The fastest way is fstat() to get the file length, malloc() a file
>> length buffer (or perhaps some portion for a very large file),
>> setvbuf() to the buffer, and do a single fread, then play in memory.
>
>Since there's a transfer buffer in between, that single `fread' will
>still be done in chunks, unless the file is less than the transfer
>buffer size (16KB by default).
The total transfer time does not seem to vary much by number of
fread()s, as timed by uclock(), unless you setvbuf() to small values.
--
Thanks. Take care, Brian Inglis Calgary, Alberta, Canada
Brian DOT Inglis AT CSi DOT com (Brian[dot]Inglis{at}SystematicSW[dot]ab[dot]ca)
fake address use address above to reply
- Raw text -