delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/12/28/04:02:43

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Trace-PostClient-IP: 68.147.177.20
From: Brian Inglis <Brian DOT Inglis AT SystematicSW DOT Invalid>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: DREADED fseek
Organization: Systematic Software
Message-ID: <dl52t0tp5o1o6e5m6savh94u3vijmuq43r@4ax.com>
References: <6a7us0he1s9ml2djpp5tlm48lod92eei5c AT 4ax DOT com> <8edus09uvkr9or13giuvdflk4ogin5q2l1 AT 4ax DOT com> <01c4ebed$Blat.v2.2.2$c5f598c0 AT zahav DOT net DOT il>
X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Lines: 46
Date: Tue, 28 Dec 2004 08:35:21 GMT
NNTP-Posting-Host: 24.71.223.147
X-Complaints-To: abuse AT shaw DOT ca
X-Trace: pd7tw3no 1104222921 24.71.223.147 (Tue, 28 Dec 2004 01:35:21 MST)
NNTP-Posting-Date: Tue, 28 Dec 2004 01:35:21 MST
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019