Re: Clearing filesystem cache. How?

From: Jeroen Geilman (nospam_at_notadaptr.nl)
Date: 09/18/03


Date: Thu, 18 Sep 2003 17:20:06 +0000

Nils Petter Vaskinn wrote:

> Hi all.
>
> I need to measure performance on a program. This program reads various
> files and to get a measurement as close to the real usage I need to make
> sure that those files are read from disk, and not from the filesystem
> cache.

Then do the obvious - write a benchmark that does just that !
Make the benchmark read so many files that you *know* they will be coming
from disk; after you've read up to $mem_size files worth of data the cache
will not be a factor...

> Is there any (easy) way to clear the filesystems buffer/cache (short of
> reading random junk into memory to fill the buffers with something else) ?

Loading garbage is next to useless, since Linux' disk cache is dynamic and
will grow to fill all available RAM - you'd have to reclaim all memory, but
that will cause swapping, rendering your benchmarks useless...

Don't know about easy...but you (or someone you know) could write a tiny C
program to mark all pages dirty and force a flush of the entire disk cache.
This would have to be a near-atomic operation, though - you have to make
sure nothing happens in between.

Just making the benchmark read so much data that you know it has to come
straight from disk is obviously the easiest way.

Really.

-- 
Jeroen Geilman
Gentoo 1.4 rc4


Relevant Pages

  • Re: Clearing filesystem cache. How?
    ... Make the benchmark read so many files that you *know* they will be coming ... from disk; after you've read up to $mem_size files worth of data the cache ... that will cause swapping, rendering your benchmarks useless... ... program to mark all pages dirty and force a flush of the entire disk cache. ...
    (comp.unix.programmer)
  • Re: DONT KNOW WHAT IS THE PROBLEM
    ... task bar manger is not ... Run the benchmark on your disk drive. ... Select "1M" or 1 million digits as the size of the test ...
    (alt.comp.hardware.pc-homebuilt)
  • Re: Ms SQL server db options for performance issues after db corruption
    ... Also, do you have a performance benchmark of the system, before the problem? ... I have a customer using Ms SQL Server 2000 SP3 installed on optical RAID-5 ... Disk Array. ... But now, cust. ...
    (microsoft.public.sqlserver.server)
  • Re: Ms SQL server db options for performance issues after db corruption
    ... Also, do you have a performance benchmark of the system, before the problem? ... I have a customer using Ms SQL Server 2000 SP3 installed on optical RAID-5 ... Disk Array. ... But now, cust. ...
    (microsoft.public.sqlserver.tools)
  • Re: Ms SQL server db options for performance issues after db corruption
    ... Also, do you have a performance benchmark of the system, before the problem? ... I have a customer using Ms SQL Server 2000 SP3 installed on optical RAID-5 ... Disk Array. ... But now, cust. ...
    (microsoft.public.sqlserver.programming)