Re: Invalidating the file cache
- From: "Don Burn" <burn@xxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 15 Mar 2007 12:44:27 -0400
For FAT at least (and I assume NTFS) reading the file with no buffering
will force a cache flush to ensure that the data is to disk. Get DiskMon
http://www.microsoft.com/technet/sysinternals/FileAndDisk/Diskmon.mspx to
watch the reads and writes from the disk.
--
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
"Ivo Beltchev" <ivo _@_ adelphia.net> wrote in message
news:Q8GdnZZ2rKEl6GTYnZ2dnUVZ_t6qnZ2d@xxxxxxxxxxxxxxx
Thanks for your response.
I'm still not clear what happens in this case.
1) I write to a file (with buffering).
2) I close the file.
3) I start reading from the same file with no buffering.
#1 and #2 may be performed by an external program, so I may not have the
power to use unbuffered writes in #1, or call FlushFileBuffers after #2.
Will the read in #3 wait for the write in #1 to complete, or will it
retrieve the data from RAM?
And lastly, is there a way to double-check that #3 doesn't read from the
cache (aside from monitoring the HDD light)?
Ivo
"Uwe Sieber" <mail@xxxxxxxxxxxxx> wrote in message
news:55qnoaF25hvtnU2@xxxxxxxxxxxxxxxxxxxxx
Ivo Beltchev wrote:
What I really need is to invalidate what's already in the cache. I
don't want to lose the benefits of cached access.
Writeing small blocks at random position there might be
benefits of cached access. Otherwise it's useless buffering
that can be done more efficient in the application because
cache can only guess what will happen to the data in fututre
while the application usually knows better.
I was thinking about FILE_FLAG_NO_BUFFERING.
http://msdn2.microsoft.com/en-us/library/aa363858.aspx says "This flag
does not affect hard disk caching.". Does that refer to the internal
HDD cache, or caching in general when accessing HDD?
It does not affect the internal HDD cache.
I am using file mapping and reading whole sectors, so the restrictions
don't affect me. I am reading the file sequentially. Is
FILE_FLAG_NO_BUFFERING going to cause any performance problems (aside
from not reading from the cache what's already there before I open the
file)? For example maybe with buffering the OS will read ahead guessing
I will need that data later, and without buffering it won't?
Writing large blocks FILE_FLAG_NO_BUFFERING is faster because
of less overhead. Of course you have to check then if
source and target are on the same physical disk or not and
read/write sequentially if yes and parallel if not.
Uwe
Ivo
"Skywing [MVP]" <skywing_NO_SPAM_@xxxxxxxxxxxxxxxxxxx> wrote in message
news:%23YYhzCfZHHA.4684@xxxxxxxxxxxxxxxxxxxxxxx
Perhaps you should open the file with FILE_FLAG_NO_BUFFERING. Be
warned
that this carries various restrictions on how you can access the file.
Also, be warned that if the hardware is doing any caching, then this
won't
guarantee that you aren't reading from a HW cache.
FILE_FLAG_NO_BUFFERING
only applies to the OS-level filesystem cache.
--
Ken Johnson (Skywing)
Windows SDK MVP
http://www.nynaeve.net
"Ivo Beltchev" <ivo _@_ adelphia.net> wrote in message
news:hu-dnXUelYQx6m7YnZ2dnUVZ_vGinZ2d@xxxxxxxxxxxxxxx
Hi
I'm working on a backup software. After I create the backup (to
optical disk
or USB drive for example) I want to verify it. But if I just start
reading
from the backup file the data is most likely still in the cache. How
do I
invalidate the read cache or otherwise make sure I really read from
the
backup media and not from the cache?
Thanks
Ivo
.
- References:
- Invalidating the file cache
- From: Ivo Beltchev
- Re: Invalidating the file cache
- From: Skywing [MVP]
- Re: Invalidating the file cache
- From: Ivo Beltchev
- Re: Invalidating the file cache
- From: Uwe Sieber
- Re: Invalidating the file cache
- From: Ivo Beltchev
- Invalidating the file cache
- Prev by Date: Re: Opening website delayed by 30 seconds
- Next by Date: Re: Invalidating the file cache
- Previous by thread: Re: Invalidating the file cache
- Next by thread: Re: Invalidating the file cache
- Index(es):
Relevant Pages
|