delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/12/27/03:33:48

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
Date: Mon, 27 Dec 2004 10:25:29 +0200
From: "Eli Zaretskii" <eliz AT gnu DOT org>
Sender: halo1 AT zahav DOT net DOT il
To: djgpp AT delorie DOT com
Message-ID: <01c4ebed$Blat.v2.2.2$c5f598c0@zahav.net.il>
X-Mailer: emacs 21.3.50 (via feedmail 8 I) and Blat ver 2.2.2
In-reply-to: <8edus09uvkr9or13giuvdflk4ogin5q2l1@4ax.com> (message from Brian
Inglis on Sun, 26 Dec 2004 22:13:39 GMT)
Subject: Re: DREADED fseek
References: <6a7us0he1s9ml2djpp5tlm48lod92eei5c AT 4ax DOT com> <8edus09uvkr9or13giuvdflk4ogin5q2l1 AT 4ax DOT com>
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> 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.

> 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).

- Raw text -


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