delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1997/09/08/22:36:05

Date: Mon, 8 Sep 1997 22:34:22 -0400 (EDT)
Message-Id: <199709090234.WAA00084@delorie.com>
From: DJ Delorie <dj AT delorie DOT com>
To: djgpp-workers AT delorie DOT com
Subject: fread slowstart

We talked about this before, and I just added it.

* The first time you read from a file, read 512 bytes.

* Each time you read, double the amount you read (limited by the
  buffer size, which is constant)

* Each time you seek, reset the amount to 512 again.

I also added a hook in fread to bump the read amount to at least what
fread() wanted, assuming that the program would continue doing that
size reads.

The idea, for those who missed it, is to optimize both these cases at
the same time, automatically:

* Reading a large file sequentially should be done by reading blocks
  as large as possible, to reduce the number of dos calls.

* Programs that fseek() a lot should read a small amount at a time, to
  avoid wasting time reading data that won't be used.

Currently, the amount starts at 512 and doubles after each read (i.e.
512, 1k, 2k, 4k, 8k, etc).  Should it quadruple instead?
(512, 2k, 8k, 32k)  That would get to the larger transfers faster, but
be less optimal for some programs that fseek a lot.

Also, I've changed the default transfer buffer size to 32k and stack
size to 512k in stub.asm.  Should we default to a max size (63.5K)
transfer buffer now ?

- Raw text -


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