Re: Benchmarking an IO library
- From: David Schwartz <davids@xxxxxxxxxxxxx>
- Date: Tue, 26 Feb 2008 21:19:45 -0800 (PST)
On Feb 26, 1:34 am, mathieu <mathieu.malate...@xxxxxxxxx> wrote:
I am currently working on an open source IO library for DICOM files.
I have been trying to optimize the reading time, and found something I
do not understand. The first time I am reading a file, the time to
read (as measured with the unix 'time' command) can be around ~24s,
while if I read it back again immediately it can be as low as ~3s.
1. Is this something known ?
2. What is this ?
Are you being serious? It's hard to imagine any even marginally
competent programmer who doesn't understand the most basic information
about memory access. The first time, the data must be read from disk.
The second time, it is still in memory. (The operating system has no
reason not to keep this data in memory. If it is never needed again,
no harm is done. If it is used again, there is a huge benefit. If the
memory is needed for some other purpose, the operating system can
simply use it for that purpose.)
3. Is there a way to control that from my application (let say I know
the list of files that need to be read next) ?
Try 'man fadvise'. Depending on what you're doing, 'mmap' and
'madvise' may be better.
DS
.
- Follow-Ups:
- Re: Benchmarking an IO library
- From: mathieu
- Re: Benchmarking an IO library
- References:
- Benchmarking an IO library
- From: mathieu
- Benchmarking an IO library
- Prev by Date: Re: segmentation fault when porting to linux
- Next by Date: Regarding global variables memory allocation and gtime funtion
- Previous by thread: Re: Benchmarking an IO library
- Next by thread: Re: Benchmarking an IO library
- Index(es):
Relevant Pages
|