The MASM Forum

General => The Campus => Topic started by: jj2007 on August 22, 2018, 07:51:26 PM

Title: How does one invalidate the file cache?
Post by: jj2007 on August 22, 2018, 07:51:26 PM
See ClearFileCache (http://masm32.com/board/index.php?topic=94.msg72735#msg72735).

FindFirstFile is the only viable way. It's not that slow, actually, provided the info is already in the cache.
Title: Re: How does one invalidate the file cache?
Post by: aw27 on August 22, 2018, 10:47:20 PM
You have the FlushFileBuffers
Title: Re: How does one invalidate the file cache?
Post by: jj2007 on August 22, 2018, 11:17:47 PM
Quote from: AW on August 22, 2018, 10:47:20 PM
You have the FlushFileBuffers

You have ideas :t
How would you use it?
Title: Re: How does one invalidate the file cache?
Post by: aw27 on August 23, 2018, 05:33:05 AM
I have used it only with pipes. I have no clear scenario to use it with files or folders - usually the cache is pretty intelligent. However, in a particularly busy system, we may need to force it to flush right away.
Title: Re: How does one invalidate the file cache?
Post by: jj2007 on August 23, 2018, 08:13:17 AM
Quote from: AW on August 23, 2018, 05:33:05 AMI have no clear scenario

I have a testbed (loops=1000):

  NanoTimer()
  For_ ct=0 To loops-1
        Open "U", #1, edi
        invoke FlushFileBuffers, MbFH[4]
        Let esi=Input$(#1, Min(MbBufSize/4, Lof(#1)))
        Close #1
  Next
  Inkey NanoTimer$(), " for FlushFileBuffers & file read"


67 ms for cached file read
3565 ms for ClearFileCache + file read
417 ms for FlushFileBuffers & file read