files and their parts in cache ?

Is there any documented way of determining in a fs minifilter if the requested part (offselt, length) of a file is already in cache by cached manager ? Thank you.

you can use “CcIsFileCached” to determine that file is being cached or not

Sam

On Wed, Jun 6, 2012 at 9:39 PM, wrote:
> Is there any documented way of determining in a fs minifilter if the requested part (offselt, length) of a file is already in cache by cached manager ? Thank you.
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule of debugging and file system seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Thank you Samuel but that only indicates if a file is cached or not. It does not tell me what parts of the files are cached ?

You don’t own the cache. Do you? That information is present as opaque structure inside shared cache map and private cache map. IMO, there is no way to find that info. And even if you find it, there is a good chance that those portions get flushed and discarded from the cache immediately after you get that information.
Maybe there is a more clean solution to your problem… So, going back to that, what is it that you are trying to achieve? Why do you want to know which portions of file are in cache?

-Ayush

On 06-Jun-2012, at 22:19, xxxxx@gmail.com wrote:

Thank you Samuel but that only indicates if a file is cached or not. It does not tell me what parts of the files are cached ?


NTFSD is sponsored by OSR

For our schedule of debugging and file system seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

The way I see it this type of information falls into the type of things in a filter where even if you could know exactly it’s hard to use the information because it can immediately change (stuff can get in and out of the cache according to very complex rules).

I find this to be very similar to virtual memory. Knowing what’s actually in physical memory at a certain time is not generally useful. What seems to be useful is the ability to lock things in physical memory when necessary.

So what are you trying to do ? Are you trying to make sure things are in the cache ? Or are you trying something like “if things are in the cache then access is pretty much free so i’ll do some operation on the data that is cached” ?

Thanks,
Alex.

Hello Alex, Im trying to develop my own MyCache. It will cache the parts of a file which are not in the SysCache. The goal is to keep a single copy of data any time. I understand that there may be situtation where still there are 2 copies or sometime none but that is ok. Any pointers will be highly appreciated.

Are you trying to do this for certain files or the whole system?

Thanks,
Alex.

whole system.

I’m not clear on what it is you’re doing. Why would you want to attempt to reimplement the cache?

Christian [MSFT]
This posting is provided “AS IS” with no warranties, and confers no rights.

Not re-implement rather compliment. I don’t know what files are being cached in the SysCache. Some applications/files are critical and I want them to stay in cache. So when SysCache kicks them out I can keep them in MyCache.

What do you mean by “critical”?

The system cache evicts data for good reasons. If the files are hot, they will remain in the cache. Even if they’re not they’ll still be there until memory pressure forces them out. Forcing more data to remain resident in memory just increases pressure on the real cache, degrading overall system performance.

Christian [MSFT]
This posting is provided “AS IS” with no warranties, and confers no rights.

The problem is SysCache is used for the entire system (in round robin fashion ?). I have observed that even if some data is hot it gets kick out due to some newly used data. I need to make sure that some of the data really stays in memory either in SysCache or MyCache.

May be you are right about degrading the overall system performance but I may care about the performance of a specific application. Also I would like to observe the implications of it by doing some tests.

Do you have suggestions for me on how to determine if a given part of a file is in SysCache ? Thank you for your help.

CcCopyRead with Wait == FALSE to some tmp scratch memory.

Be sure to properly holds the locks required to call CcCopyRead.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

wrote in message news:xxxxx@ntfsd…
> Is there any documented way of determining in a fs minifilter if the requested part (offselt, length) of a file is already in cache by cached manager ? Thank you.
>

> CcCopyRead with Wait == FALSE to some tmp scratch memory.

Or map the hot file as a section and keep on touching the hot area. It may
get evicted from cache, but it will software pagefault in again. You can do
this in usermode. If you know that the file is really really really hot you
could lock the pages down…