Re: Is there a way to flush the file cache?
- From: Jean-David Beyer <jeandavid8@xxxxxxxxxxx>
- Date: Fri, 29 Dec 2006 12:39:20 GMT
Tony Lawrence wrote:
General Schvantzkoph wrote:
On Thu, 28 Dec 2006 13:29:24 -0800, Tony Lawrence wrote:
General Schvantzkoph wrote:What I want to do is the following,
I'm writing a system exerciser that checks memory and disk I/O. Is there a
C call that flushes the file cache so that I can be assured that my freads
are coming from the disk and not the RAM. I'm using a sync() but I don't
think that does the whole job, it guarantees that the disk writes happen
but I don't think it clears out the file cache.
Well, of course it can't guarantee that some random app hasn't written
data, if that's what you mean..
1) Create a file and write it to the disk.
2) Read that file off of the disk and then check it.
I'm trying to check the SATA interfaces so it's important that the file go
to and from the disks. The file cache interferes with this because if the
file is present in the cache the program will get the cached copy not the
copy that is on the disk. The sync() call forces the disk writes to happen
immediately which is half of the battle. The other half is to purge the
file cache so that all subsequent file reads come from the disk. Is there
a way to do this?
O, I see now: you are checking disk performance or maybe even checking
disk integrity.
No, sync won't help with that (because the read can still come from
cache). What you need to do is overwrite the cache with new data
unrelated to the blocks you want to read. That could be as simple as a
well placed "ls -lR".. or much more complex. See
http://www.linuxjournal.com/article/7105
On my machine, I have 8 GBytes RAM, and usually over 3/4 of it are used by
IO buffers and cache. It would take a lot to flush all that. In fact, sync
does not do it.
Apparently newer kernels have made this easier:
http://linux-mm.org/Drop_Caches
--
.~. Jean-David Beyer Registered Linux User 85642.
/V\ PGP-Key: 9A2FC99A Registered Machine 241939.
/( )\ Shrewsbury, New Jersey http://counter.li.org
^^-^^ 07:35:01 up 69 days, 10:07, 3 users, load average: 4.18, 4.30, 4.22
.
- Follow-Ups:
- Re: Is there a way to flush the file cache?
- From: Tony Lawrence
- Re: Is there a way to flush the file cache?
- References:
- Is there a way to flush the file cache?
- From: General Schvantzkoph
- Re: Is there a way to flush the file cache?
- From: Tony Lawrence
- Re: Is there a way to flush the file cache?
- From: General Schvantzkoph
- Re: Is there a way to flush the file cache?
- From: Tony Lawrence
- Is there a way to flush the file cache?
- Prev by Date: Re: Is there a way to flush the file cache?
- Next by Date: Re: Problem compiling VIM sources on Ubuntu
- Previous by thread: Re: Is there a way to flush the file cache?
- Next by thread: Re: Is there a way to flush the file cache?
- Index(es):
Relevant Pages
|