SuperFetch (and Prefetch)

ubuysa

The BSOD Doctor
SuperFetch has generated controversy ever since it first appeared in Windows Vista. If you do a web search for 'Superfetch' today you'll see no end of posts with dire warnings to turn it off or your disk will explode and your PC will melt.

What is this thing called SuperFetch then, what does it do, and do I need it?

SuperFetch is an enhancement to an earlier performance aid call Prefetch. Prefetch and SuperFetch have a single and very simple goal; to reduce the number of reads from disk whilst an application is running. Reading data from a disk (even an SSD) is painfully slow in terms of CPU and RAM cycle time and if it can be avoided then it should be.

Where Prefetch and SuperFetch differ is in the applications affected...

Prefetch (introduced in Windows XP) pre-loads the files an application uses as it starts, this improves the performance of the application when running (by avoiding those disk reads) and gives the user a more responsive experience. Prefetch monitors the files used by each application as they start and records this information on disk. When an application is next started, Prefetch uses the recorded information to pre-load files into RAM so that the application is 'ready to go'. Prefetch is thus designed to improve the performance of applications you are using now.

SuperFetch (introduced in Windows Vista) is designed to identify the way the user uses applications and to look for patterns in use. For example, after starting Windows the user might always open their email client followed by the web browser. SuperFetch records these usage patterns and uses the Prefetch tool to pre-load RAM with the files for the applications that it expects the user to open next, so that the user has an even more responsive experience. SuperFetch is thus predictive, it tries to predict the user's actions and pre-load RAM with pages for applications that it expects the user to open next.

Both Prefetch and SuperFetch use Standby memory for their pre-loads, these pages can be brought into a process's working set by simple page table updates when they are first referenced. In addition, SuperFetch is closely involved in managing working set sizes (those pages in RAM that a process is using now) and which pages are kept in Standby memory. There is a clear performance benefit in managing the pages in Standby memory so that it always holds pages that are likely to be wanted again, instead of the default method of simply putting any and all stolen pages in there regardless of their activity history in the hope they might be needed sometime.

Although SuperFetch activity does require a lot of I/O (input/output operations) in reading pages into Standby memory it uses the very lowest I/O priority on the system, which means that the I/O activity of SuperFetch is queued behind all other I/O activity in order to minimise the impact on the system.

SuperFetch is also involved in the Hibernate and Standby scenarios. Whenever either of these is selected, SuperFetch decides how big each process working set should be and which other pages in Standby memory should be included and saved with it. The goal again is that when the system is resumed from either a hibernate or a standby no process has to access the disk because all their necessary pages have been pre-loaded into RAM (either as working set pages or as Standby memory pages).


Prefetch and SuperFetch in practice

There is no such thing as a free lunch, so the performance improvements that Prefetch and SuperFetch bring come at a cost.

With Prefetch a process takes a performance hit at startup time as the files the process uses are pre-loaded into RAM, depending on the speed and performance of the disk this delay can be noticeable. Slow hard disks and poorly managed hard disks can introduce significant delays in process start in order to offer a 'snappier' experience once it has started. This is often the case at boot time because Prefetch pre-loads files at boot time too in order to make the booting process 'snappier'. There is already a lot of disk activity at boot time and adding the extra activity of Prefetch can sometimes overwhelm a slow and/or poorly managed hard disk. In most cases (though there can be exceptions) Prefetch brings valuable gains to application (and booting) performance on all systems.

With SuperFetch attempting to predict the user's actions, a performance hit might be taken now in the hope that when (and if) the user does start this application in the near future it will be a much 'snappier' experience. Again, a slow and/or poorly managed hard disk can cause performance issues in applications running now, as files are pre-loaded for an application you haven't even started yet - and may not start at all. This is exacerbated if the applications running now are big hard disk users, the added activity of SuperFetch can overwhelm a slow and/or poorly managed hard disk.

In addition, pre-loading files for applications you haven't yet started requires RAM to hold them. It might be Standby memory but you still need physical RAM pages to store it. In a system that is short of RAM, or even one that is just a little tight on RAM, this results in quite aggressive working set trimming (a reduction in the pages processes can access now) to create the space in RAM for files for an application not even loaded yet. Reduced working set sizes increases the probability of hard page faults and this makes those applications running now appear sluggish.

There are thus many systems where SuperFetch itself is a performance problem. These tend to be systems that are already short of RAM (4GB or less for example) and which have poorly managed and slow hard disks (a single 5400rpm HDD for example). In other words, they tend to be older systems. On these systems it probably is wise to disable SuperFetch if it causes problems, though not Prefetch - that still benefits applications even on these older slower systems because they will want that file data in RAM eventually.

SuperFetch is at its best in systems with a decent amount of RAM (so that there is plenty of Standby memory) and with fast and well managed HDDs. Since the Prefetch files that are used by SuperFetch are stored on the system drive (in C:\Windows\Prefetch), as are most of the files that will be loaded (typically DLLs), having an SSD as the system drive improves both Prefetch and SuperFetch performance. In these systems you very often find that all the pages you need for the application you are about to start are already in RAM, thanks to SuperFetch, and all the Windows memory manager has to do is update page tables to include them in the working set of the application as you start it. What you see is applications starting almost instantly and running smoothly, and because you're not short of RAM (and you have an SSD) the pre-loading of these pages did not adversely impact the performance of the applications you were using at the time.

If SuperFetch detects that the user's current usage pattern is not that which it expected then SuperFetch 'backs off' pre-loading files and instead concentrates on learning the new usage patterns, so that it doesn't pollute Standby memory unnecessarily. If the user's usage patters become particularly erratic the result is little different to what would be seen with SuperFetch turned off.

My advice is that everyone should leave Prefetch enabled on whatever system they have, it's pre-loading into RAM those files that you will eventually want with this application. Those users with limited RAM (4GB or less as a rough rule of thumb) and with a single slow hard drive (5400rpm) and no SSD might want to consider disabling SuperFetch if doing so improves overall system performance (and it well might). Everyone else, and especially those with at least 8GB of RAM and an SSD as their system drive will generally see a much more responsive system with SuperFetch turned on (though there are always exceptions of course).


Controlling SuperFetch

In Windows 10 SuperFetch is on by default for both the boot process and for applications, so those with ample RAM and SSDs need to do nothing to get the benefits.

There are two ways to turn SuperFetch off should you want to (and you need to be sure that SuperFetch is your problem before turning it off). You can disable the SuperFetch service, which turns it off completely, or you can enable SuperFetch just for the boot process or just for applications via a registry key.

To turn the SuperFetch service off enter 'services.msc' in the Run box and scroll down to the SuperFetch entry in the dialog that opens. Right-click on SuperFetch and select Properties. In the dialog that opens change the Startup Type to Disabled, click the Stop button and then click Ok.

To manage SuperFetch via the registry key enter 'regedit' into the Run box to open the registry editor. BE VERY CERTAIN THAT YOU KNOW WHAT YOU'RE DOING WITH THE REGISTRY EDITOR! Navigate to the key HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\PrefetchParameters and add a DWORD (32 bit) value called 'EnableSuperfetch' (if it doesn't already exist), give it one of the following values:

0 - To disable all SuperFetch functions
1 - To enable SuperFetch only for applications
2 - To enable SuperFetch only for booting
3 - To enable SuperFetch for everything


Gaming and SuperFetch

I don't game so I have no practical experience of how SuperFetch behaves on systems used predominantly for gaming. Perhaps those gamers on here who have experimented with SuperFetch would like to add their comments? :)
 
Last edited:

Tony1044

Prolific Poster
I love a bit of SuperFetch - I can reduce thin clients with embedded Windows' boot time by almost a third with a bit of judicious use of it.
 
Top