🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #15453

Re: Optimal File Read Buffer Size?

#15453
From: Michael Kelly
Date: Sat, 28 Jun 2003 16:29
39 lines
2422 bytes
Muhammad Momin Rashid wrote:

> Hi,
> 
> I remember someone telling me (on this very forum), that the optimal
> buffer
> size is 32k or 64k.

Something like that may have been valid in the old Dos days
when any buffer larger than 64KB would require a so called
Huge Pointer to access.  Nowadays the main trick for reading
large files is to use a large buffer, but not so large that
the OS has to swap to allocate the memory.  IOW, it does
no good to have a 64MB buffer for reading a large video file,
as example, if the OS is going to spend 5 minutes playing
with the swap file.  Best to get some system params, see
how much physical ram is available etc.. and take a guess
as to how much buffer to allocate.

Perhaps some benchmark scenarios tried out on various
machines with various amounts of ram under a few different
load conditions etc. would help.

There's no one answer.  Of course your approach should
vary depending on the task.  If you are reading, processing
and writing data out to file in a loop that would be
different than just trying to get the file in ram ASAP.

Try some bechmarks.  Another thing that might not occur
to you too is some people use external drives through
reletively slow interfaces such as USB.  You might
not think sucking up a few MB from a file would require
a "please wait" in the user interface until you see
somebody running your app through one of those! :)


-- 

"Only choice is an oxymoron."
Technical Details
Message-ID: <3efdc328@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-08!supernews.com!border3.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <3ef93631@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,7650bbfb9a010dc6
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-06-28 09:35:18 PST
Message-ID: <3efdc328@newsgroups.borland.com>
From: Michael Kelly <mkelly2002@adelphia.net>
Subject: Re: Optimal File Read Buffer Size?
Newsgroups: borland.public.cppbuilder.nativeapi
Date: Sat, 28 Jun 2003 12:29:55 -0400
References: <3ef93631@newsgroups.borland.com>
Lines: 40
User-Agent: KNode/0.7.1
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7Bit
NNTP-Posting-Host: 68.68.251.232
X-Trace: newsgroups.borland.com 1056817996 68.68.251.232 (28 Jun 2003 09:33:16 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-08!supernews.com!border3.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail