how to knock a page out of file cache

B

birdsong

Can anyone recommend a way to read a file ensuring that it is not
coming from file cache on Linux?

I'm trying to write a metric script for measuring http connect + read
times from a web server over localhost. I want to plot both file
cache read times and non-cached files.

I thought of simply opening and writing to the file to dirty it's
pages, but there no guarantee that pdflush will have already written
the dirty pages to disk -pretty sure it depends on all the dirty ratio
and intervals.

Does anybody know of a system call that will 'knock' the file out of
file cache? Can madvise or fadvise do this?

I know this is mostly a unix question, but I'm asking in the context
of how to do this in python.
 
P

Paul Rubin

birdsong said:
Does anybody know of a system call that will 'knock' the file out of
file cache? Can madvise or fadvise do this?

I don't think so. Best I can think of is unmount and remount the file
system. And I don't know if even that is guaranteed if you don't
physically remove/unplug the device.
 
I

Ishwor Gurung

[...]
I thought of simply opening and writing to the file to dirty it's
pages, but there no guarantee that pdflush will have already written
the dirty pages to disk -pretty sure it depends on all the dirty ratio
and intervals.

Does anybody know of a system call that will 'knock' the file out of
file cache?  Can madvise or fadvise do this?

Does this help http://www.westnet.com/~gsmith/content/linux-pdflush.htm ?
(Getting hold of procfs and doing it in Python?)

Also, are you looking for sync(2) http://linux.die.net/man/2/sync?

[...]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top