Superfetch: A concise answer

Soldato
Joined
2 Sep 2006
Posts
13,483
Location
Forest Grove, OR, 'Merica
What does it do?
How is it implemented?
Does it take any sort of time to be overwritten when memory is requested?
Does it ever write to the hard drive?
What makes anyone think disabling it will make it faster, and why are they wrong?

So I don't have a total understanding of this but have come across people disabling it by dozens.

Would like just a clear explanation of it if anyone has the time, thanks.
 
Superfetch builds up patterns on which files on your hard disks are used most frequently or are highly likely to benefit from caching. Then whenever there is some free memory the superfetch background service will find something on the hard disk which would benefit from being pulled into the memory and it does so.

It is implemented in the form of low-level kernel support and a background service which does all the reading of files and mapping them into memory.

When a program needs to allocate some memory the kernel may determine the best course of action is to use some memory that is currently in use by Superfetch. This is not a problem. There is no performance hit (to even think otherwise is hilarious). The performance is identical to a "regular" memory allocation.

On some systems that have very slow hard disks (laptops) disabling Superfetch can sometimes give a more focused desktop experience. It can also save battery life for these systems. Also there is not really much gain for systems with less than 1GB of memory. Though the Superfetch on Windows 7 is slightly improved in detecting these particular hardware characteristics and dramatically changes its behaviour.
 
What does it do?
Caches commonly used programs (exe's and dlls) so the system is more responsible into RAM. It doesn't cache user files (.doc, xls etc.)

How is it implemented?
On by default on Vista / Windows 7, there are registry key settings you can change to alter how it works in Vista.

Does it take any sort of time to be overwritten when memory is requested?
No idea, but it will be replaced by any apps that need the RAM before it hits the swap file.

Does it ever write to the hard drive?
No - pretty sure that's readyboost.

What makes anyone think disabling it will make it faster, and why are they wrong?
It was very aggressive in Vista, it'd hammer your HDD on startup as it filled the RAM cache, it's much much better in Windows 7. In 7 it tends to wait on the PC being idle or after a few minutes post boot to start filling the cache, likewise it doesn't tend to refill the cache when apps have been exited and it's become free.

So I don't have a total understanding of this but have come across people disabling it by dozens.
Vista gave it a very bad rep.


This is all done from memory so I'm happy for anyone to correct me where I'm wrong :D

Edit: Nathan's explanation above pretty much covers it I think, in a far more technical fashion which is always good! (1 too many beers tonight - sorry.)
 
If you load a big game or application up you may find a large portion of the Superfetch cache gets overwritten and lost. This is not a problem. Because when some memory becomes free again (i.e. you close that big game or app) the Superfetch background service will detect this and start rebuilding your cache again.
 
All Superfetch read operations are low priority (prioritised I/O was a new kernel feature in Vista). So if literally any other program wants to do some I/O then it will automatically take precedence over Superfetch. The Superfetch read requests also have short timeouts so if they stay in the I/O queue for more than a couple seconds they will expire and the background service will have to rerequest them at a later time (although it takes such an error as a hint that it should also backoff because the system's I/O is clearly under load).
 
Superfetch does not do any disk write operations. Obviously apart from persisting its statistical knowledge of which files it has learnt to cache. Which, I might add, after a few months is like gold dust in PC performance.
 
Just 1 more....please give me several reasons why I shouldn't disable the pagefile.

Thanks :)
 
Last edited:
Just 1 more....please give me several reasons why I shouldn't disable the pagefile.

Thanks :)

Because windows, and by extension, many programs, expect the pagefile to be available. Disabling the pagefile gives no performance benefit at all, but can result in reduced performance due to certain operations being prioritised to the pagefile first and finding it missing and starting the process again. Vista and Windows 7 are much better and much more sophisticated when managing the pagefile than previous versions of windows, can resize and reallocate on the fly much more successfully, and basically Windows is much better at managing it these days than you are :)
 
Just 1 more....please give me several reasons why I shouldn't disable the pagefile.

Thanks :)

1. It prevents virtualised memory addressing from occuring correctly. Meaning the ability for the OS to multi-task is seriously restricted.

2. It wastes RAM on pages of memory that possibly haven't been read or written for days/weeks/months or worse.

3. It slows the system down due to unnecessary stress on the kernel memory manager causing additional CPU usage.

4. Memory fragmentation occurs far more easily meaning eventually programs may start getting rejections to their memory allocation requests.

5. Scalability of the OS is reduced by several magnitudes.



Think of it like this. Paging is a bit like owning a filing cabinet. If you don't have one you just have a stack of papers on your desk and before long it is a mess and you have to keep sorting it all the time. Whereas a filing cabinet lets you stow away things that you aren't using for the time being. But you can easily 'recall' them just by fetching them from the cabinet. However this filing cabinet can only store 1 to 1.5x the amount of paper as what would have fitted on your desk if you were to lay them all out.

The page file is this filing cabinet.
 
There is a very strange myth about page files. Some people think a whole program is either paged in or paged out. This is not correct. Whilst it is entirely possible for a whole program to paged in or out, by coincidence. This is not the actual granularity that paging operates on.

All virtual memory operates on a 4KB scale. A page of memory is always 4 kilobytes. This is just how x86 and AMD64 instruction set CPUs are. By comparison, Intel Itanium has 8KB pages.

Using the file cabinet analogy, think of this 4KB pages as an A4 sheet of paper. That's the ONLY size that the cabinet can store. In fact that is the only size of paper allowed on both the desk AND the inside the filing cabinet.

It is entirely possible for 90% of a program to be paged out but just the remaining 10% to be paged in (i.e. in RAM) and for that program to execute just fine. In this scenario the memory manager would have realised that hardly any of the program was needed to be in RAM so it decided to page most of it out. If for some reason the program needs one of those paged out pages of memory. It can still request it. But the MMU unit on the CPU will realise the requested page of memory is paged out (yes this stuff is baked straight onto CPUs) and it will raise a 'page fault' hardware interrupt. The kernel will intercept this interrupt and respond to it by bringing that page of memory back in from the page file and locating it in a free piece of RAM. If necessary, it will page OUT some other idle page of memory in order to make room for the active page fault. Then it will schedule the thread of the interrupted process again so that it can resume from where it left off and access the page of memory that it requested.
 
I found it was constantly spanking the hard drive on Grandad's laptop, to the point where everything runs very slowly.

The laptop is used infrequently and for short periods of time. Turning it off the machine is much faster.
 
Back
Top Bottom