Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(/home/bitsum/public_html/forum/Sources/Facebook/FacebookHooks.php) is not within the allowed path(s): (/home/bitsumll:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/bitsumll/public_html/forum/Sources/Load.php on line 290
Memory caching in Windows (7)

Author Topic: Memory caching in Windows (7)  (Read 236 times)

Offline DeadHead

  • Full Member
  • ***
  • Join Date: Mar 2011
  • Posts: 47
  • [A newly registered member with no personal text written here]
Memory caching in Windows (7)
« on: January 13, 2012, 12:58:50 PM »
I'd like to ask a few questions about Windows (7) memory caching and Windows memory management in general.

I recently upgraded my computer (I7 920@3.6 GHz, Windows 7 Pro) from 6 gigabyte memory to 24 gigabyte memory. Yes, this is a *total* overkill for me as a regular homeuser, but since the upgrade was so cheap (less money than I spend on my original 6 gig!) I thought - why not?

Anyway, since I now have this huge amount of memory to play with, I naturally want to make as much use of it as possible.

The first thing I did was to install a ramdisk from company X. This particular ramdisk is most unique, because it has dynamic memory management. In short, this means that I can set it up to any size I want, depending only on the license I bought and the actual amount of physical ram memory that I have. So, I set this ramdisk up to use 8 gigabyte of ram. However, this ramdisk will only use the amount that is actually stored on the ramdisk. Also, if I delete files from the ramdisk, memory will be released! Not since the glorious days of the Amiga have I been able to find a ramdisk for Windows that has this ability.

Well, that right there is a nice way to utilize the huge amount of ram I have at my disposal. I can store "crap"-files on the ramdisk, use it for temporary files, extract archives, set junction points for games and so on.

What would be of more interest to me though, is the ability to cache more things from the harddrive into physical ram for blistering fast file access. I know that Windows by itself uses a number of techniques to cache files to ram, through prefetch and also when I run an application, it will store (some) of that data needed to run that particular application.

If I don't turn off my computer, but instead use the Power saving mode, that file cache will continue to grow, and after several days of use, opening different applications, eventually I will fill up all available memory with cached data - which is a good thing!

What I miss in Windows though, is a simple way to cache on demand! For example, I got this rather crappy coded mmo that is extremely disk intesive. It takes up +14 gigabyte of harddisk space. Due to the crappy coding, this game constantly reads from the harddisk, which leads to stuttering gameplay, even though I got a computer that crushes even the recommended specs for this particular game. Clearly, in this case, harddisk activity is the culprit for crappy performance.

So, sitting there with 24 gigabytes of ram to spare, playing a 32 bit game that won't use more than 2 gigabytes of memory, I see all this performance this game *could and should* utilize in a system like mine simply go to waste.

I guess I could of course copy the entire game to the ramdisk and run it from there, but that's not a very neat solution to this problem imho. What I would *really* like to be able to do, would be to precache the entire game/application on demand, OR (depending on actual ram any user might have) precache as much as the system would allow - on demand!

So, Jeremy or anyone else, can you see the issue(s) here, and see the need for solution to this?

Offline bitsum.support

  • Administrator
  • Hero Member
  • *****
  • Join Date: Jul 2008
  • Posts: 1924
  • Gender: Male
  • Bitsum Technologies Support
    • Bitsum Technologies
Re: Memory caching in Windows (7)
« Reply #1 on: January 13, 2012, 06:44:44 PM »
First, although you know, let me clear up some some possible misconceptions for readers. The Windows file/disk cache is kept in what is considered 'free' RAM. It is *never* paged out, except in the new SuperFetch technology, which still isn't paged out, but is written to disk. When RAM containing disk/file cache is needed, this cache is just 'tossed out', as its just a cache and can go be retrieved again later. Well, assuming it isn't a write-back cache, then it needs flushed to disk.

So, don't worry about your cache 'filling up' or 'wasting' RAM, that's just not how it works. You want your RAM used 100% because that's the fastest storage you have on your PC. Now, most older task managers, and Process Lasso, show you X% used, and the rest as Free RAM. This area of Free RAM is where the file/disk cache is, as I mentioned, and something you can see more visibly in the new Resource Monitor of Vista+. If this RAM were NOT filled with anything, then you'd just be wasting it.

SuperFetch, on the other hand, is a different technology. It tries to gather what you most commonly use and *does* write them to disk so that it can keep a 'collection'. However, this 'smart cache' should always help and never hurt, in theory. On high end machines where it isn't needed, perhaps it is best to turn off. Do not confuse SuperFetch with ReadyBoost. ReadyBoost uses the smart cache of SuperFetch to know what stuff it should put on the USB key or other (faster) media.

Could there be situations where the standard disk/file cache or SuperFetch malfunctions, to the detriment of the system? ... possibly. I can not rule this out.
« Last Edit: January 14, 2012, 05:38:55 PM by bitsum.support »

Offline DeadHead

  • Full Member
  • ***
  • Join Date: Mar 2011
  • Posts: 47
  • [A newly registered member with no personal text written here]
Re: Memory caching in Windows (7)
« Reply #2 on: January 14, 2012, 01:35:58 AM »
Thanks Jeremy, but what I'm after here is a way to, on occasion, cache-on-demand (or should i say PREcache-on-demand) a particular application and/or folder. This should of course go to the standard memory cache like Windows already do by itself.

Offline bitsum.support

  • Administrator
  • Hero Member
  • *****
  • Join Date: Jul 2008
  • Posts: 1924
  • Gender: Male
  • Bitsum Technologies Support
    • Bitsum Technologies
Re: Memory caching in Windows (7)
« Reply #3 on: January 14, 2012, 02:08:04 PM »
Thanks Jeremy, but what I'm after here is a way to, on occasion, cache-on-demand (or should i say PREcache-on-demand) a particular application and/or folder. This should of course go to the standard memory cache like Windows already do by itself.

Sorry, I misunderstood in my speed-reading.

User requested caching isn't available, indeed... I dunno about that, you'd have to do lots of mods to the system to create such a thing. The pre-fetch is what SuperFetch does, theoretically. It builds that list of common stuff, then loads them up into memory when you boot your PC.

Now, it might be possible to force something to be put into the cache by frequently accessing it. However, if you frequently access it, then surely it is in the cache. Selectively telling Windows not to cache stuff would be nice, but there's no current way to do that, and it would require lots of low-level and tightly coupled code to work. Very difficult.

Offline bitsum.support

  • Administrator
  • Hero Member
  • *****
  • Join Date: Jul 2008
  • Posts: 1924
  • Gender: Male
  • Bitsum Technologies Support
    • Bitsum Technologies
Re: Memory caching in Windows (7)
« Reply #4 on: January 14, 2012, 02:36:15 PM »
Thinking about it further, there might be some way to rig up a system to force Windows to cache only what you want, but it isn't trivial stuff ... I will have to think on it. Ideally, it would be nice to have an interface into SuperFetch, so you could tell SuperFetch what you want in its prefetch/smart cache.

Online edkiefer

  • Global Moderator
  • Sr. Member
  • *****
  • Join Date: Feb 2011
  • Posts: 133
  • Gender: Male
Re: Memory caching in Windows (7)
« Reply #5 on: January 14, 2012, 04:22:58 PM »
Maybe this might help .
I did quick search and this seems to give path of data files in OS .

MS may have a doc/info too but this seems good info (i think ).


http://www.osnews.com/story/21471/SuperFetch_How_it_Works_Myths

Offline bitsum.support

  • Administrator
  • Hero Member
  • *****
  • Join Date: Jul 2008
  • Posts: 1924
  • Gender: Male
  • Bitsum Technologies Support
    • Bitsum Technologies
Re: Memory caching in Windows (7)
« Reply #6 on: January 14, 2012, 05:33:54 PM »
Yes, it says what I was trying to say, that SuperFetch stores its cached data on disk (in those .pf files), so that it can readily pre-fetch them into RAM on boot or user login... or slap them on a new ReadyBoost storage device inserted into the PC.

However, there's no high level interface to tell SuperFetch what to cache and what not to. You can delete it's .pf files, but the behavior then is unpredictable - and it'd likely just refill them. It most likely has a database (update: I see it does, in .db files stores in the same location). These need modified, and the format of such likely isn't documented anywhere. I would have to really dig into this. It is an interesting topic, though I must admit that I have doubts about user-controlled caching being more effective than smart caching based on what is accessed most frequently.

An ideal compromise would be 'sets' of SuperFetch caches. For instance, you might have a 'game' SuperFetch cache and a 'work' SuperFetch cache. Selecting between them would allow you to choose which cache is applicable, which I believe is your goal here.

Online edkiefer

  • Global Moderator
  • Sr. Member
  • *****
  • Join Date: Feb 2011
  • Posts: 133
  • Gender: Male
Re: Memory caching in Windows (7)
« Reply #7 on: January 14, 2012, 06:56:35 PM »
Yes, I have XP and looks like ini file is whats loaded and then you have the app .PF files .

There would need to be a way to have multiple db files and then added PF files and way to switch without windows altering any of the user edited "app profiles db ' . I am not sure this would work, meaning if your able to change how OS default does things .

Offline bitsum.support

  • Administrator
  • Hero Member
  • *****
  • Join Date: Jul 2008
  • Posts: 1924
  • Gender: Male
  • Bitsum Technologies Support
    • Bitsum Technologies
Re: Memory caching in Windows (7)
« Reply #8 on: January 14, 2012, 07:03:27 PM »
Yes, I have XP and looks like ini file is whats loaded and then you have the app .PF files .

In XP this prefetching is not the same as SuperFetch. They use a different technology to try to boost the speed of system boot by prefetching files accessed during bootup, but its very similar, SuperFetch in Vista was a (large) extension of it.

Quote
There would need to be a way to have multiple db files and then added PF files and way to switch without windows altering any of the user edited "app profiles db ' . I am not sure this would work, meaning if your able to change how OS default does things .

Yes, but this may or may not work. More study would have to be done, much more study. SuperFetch is very tightly integrated into the system at a very low level. The effects of suddenly swapping out the storage directory (or files) is unknown.

Online edkiefer

  • Global Moderator
  • Sr. Member
  • *****
  • Join Date: Feb 2011
  • Posts: 133
  • Gender: Male
Re: Memory caching in Windows (7)
« Reply #9 on: January 14, 2012, 07:24:29 PM »
right , I know XP is like first version and vista/win7 superFetch is more advanced/broader system (its what I have to look at at moment) .

I assume this data gets loaded at bootup or is it updated over time (dynamically loaded) ,if system is not rebooted a lot , if it can do dynamically then it might work if you could get info or what makes it work in detail .

And of course if it is worth it , performance wise .

Offline bitsum.support

  • Administrator
  • Hero Member
  • *****
  • Join Date: Jul 2008
  • Posts: 1924
  • Gender: Male
  • Bitsum Technologies Support
    • Bitsum Technologies
Re: Memory caching in Windows (7)
« Reply #10 on: January 15, 2012, 03:08:10 AM »
The entire mechanism, and file formats, could be reverse engineered and documented. However, I'm just not sure of its utility. I mean, what more do you want cached that 'all my recently and frequently used stuff'? In certain situations, SuperFetch profiles might be useful, but only if there is a limited amount of RAM. Also, we don't know how smart SuperFetch is for sure, it might even already use a type of profile system. If it does, that could be a point of potential failure, as it introduces additional complexity.

Offline DeadHead

  • Full Member
  • ***
  • Join Date: Mar 2011
  • Posts: 47
  • [A newly registered member with no personal text written here]
Re: Memory caching in Windows (7)
« Reply #11 on: January 15, 2012, 03:40:01 AM »
I would rather see another solution than superfetch. If I had my way with something like this, it would be being able to right-click a folder and choose something like "cache this folder into ram", perhaps with the option to store caching profiles that I could load, so that I wouldn't have to dig through explorer each and every time to find the particular folder of "game x the disk hog" ;)
Since I think the built in cache-system in Windows do a very good job on it's own, it's only under certain circumstances that I would like to be able to override what it is caching, like I mentioned in my first post.