evict file from windows file system cache

Let’s say there’s a zzz.exe that I didn’t write. It reads c:\file.txt. Thus
that file is often in the windows file system cache. How can I write an app
that clears just that file (or that directory) from the windows file system
cache?

I’m doing performance testing of that zzz.exe app. Performance varies
drastically based on whether that underlying file is in the windows file
system cache or not. So I want to write a tool to evict it so tests will be
more consistent and so I can optimize performance on cold cache.

Any pointers or suggestions would be appreciated. I’m targeting mainly
Win2003.

MessageSame answer today as yesterday. Reboot the system. Some things require the OS be reloaded back to a known state to ensure you can duplicate a test with no variations that may impact the test. Yes, you can do a large sequential file read where the file is larger than 2 times the amount of memory on the system, but each test will be starting in a little different state. It may be close enough for government work - if that is an acceptable standard for your environment. You just can’t have everything you want and this is one of those things you can’t have.

If you have the source code to Windows, you might be able with several hours of research into the appropriate filesystem, cache manager, and memory manager to find a way to get it done programatically. Only the source to fastfat for the various forms of FAT volumes is publically available.

“Greg Galloway” wrote in message news:xxxxx@ntfsd…
Let’s say there’s a zzz.exe that I didn’t write. It reads c:\file.txt. Thus that file is often in the windows file system cache. How can I write an app that clears just that file (or that directory) from the windows file system cache?

I’m doing performance testing of that zzz.exe app. Performance varies drastically based on whether that underlying file is in the windows file system cache or not. So I want to write a tool to evict it so tests will be more consistent and so I can optimize performance on cold cache.

Any pointers or suggestions would be appreciated. I’m targeting mainly Win2003.

David,

Having spent more than serveral hours looking at that question, your
answer of “reboot” is the only correct one.

If you do not want to reboot you need to manage things yourself,
typically this is done by having a secondary file object and that every call
(yes for a mini-filter this means filling in all callback) hands things off
to the secondary object. Then since you can control the secondary object
completely, you can control the references to the file enough to ensure that
the low level flush calls will work. This takes a lot of work and effort to
even make it work, and more for speed and efficiency.


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply

“David Craig” wrote in message news:xxxxx@ntfsd…
MessageSame answer today as yesterday. Reboot the system. Some things
require the OS be reloaded back to a known state to ensure you can duplicate
a test with no variations that may impact the test. Yes, you can do a large
sequential file read where the file is larger than 2 times the amount of
memory on the system, but each test will be starting in a little different
state. It may be close enough for government work - if that is an
acceptable standard for your environment. You just can’t have everything
you want and this is one of those things you can’t have.

If you have the source code to Windows, you might be able with several hours
of research into the appropriate filesystem, cache manager, and memory
manager to find a way to get it done programatically. Only the source to
fastfat for the various forms of FAT volumes is publically available.

Reboot, or remount the volume on which the file resides. This can be done
by revoking and then reassigning the drive letter in Disk Management.


Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

“Greg Galloway” wrote in message
news:xxxxx@ntfsd…
> Let’s say there’s a zzz.exe that I didn’t write. It reads c:\file.txt. Thus
> that file is often in the windows file system cache. How can I write an app
> that clears just that file (or that directory) from the windows file system
> cache?
>
> I’m doing performance testing of that zzz.exe app. Performance varies
> drastically based on whether that underlying file is in the windows file
> system cache or not. So I want to write a tool to evict it so tests will be
> more consistent and so I can optimize performance on cold cache.
>
> Any pointers or suggestions would be appreciated. I’m targeting mainly
> Win2003.
>
>