What is Prefetching?
Have you ever wondered how it is that your machine can operate so quickly? Although there may be many technical reasons, one of them may be prefetch. If you are like most people, you have probably never heard the term prefetch.
Basically, prefetching is like asking a dog to go fetch a bone for you only to find out that he’s already done so even before you asked.
The prefetch folder is found in your Windows folder. Like other programs, prefetch is on your hard disk.
How do you find your prefetch folder?
Alternately, prefetch can be
N:\windows\prefetch. N is the drive where Windows is installed.
Taking either the system root or N:\windows route will lead you to your local system. The second route is more commonly used if you have Windows installed by default in C:\.
What does prefetch do?
Your machine keeps tracks of the things you do and the programs you need. Windows XP gets programs ready that it thinks you might need even before you ask for them.
Clearing out your prefetch folder and altering prefetch behavior through your registry will give you a speedier computer.
Many tech sites advise you to clear out your prefetch folder to increase Windows XP’s performance and speed. The idea behind doing this is to clear out your prefetch folder. You can perform this task by using the following registry tweak.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\PrefetchParameters
You are then advised to choose from the following values to enter in your value data:
0 – This disables prefetch.
1 – Application Launch prefetch (to prefetch application launch files)
2 – Boot prefetch (to prefetch boot files)
3 – Prefetch all (Default)
You will notice that most sites that advise you to do this simply provide you with instructions on how to perform the tweak. No benchmarks or performance tests are done.
However, notice how sites that advise against clearing out your prefetch folder and tweaking your registry are more passionate and more detailed in their advice. Performance tests are also conducted to really find out whether or not clearing the prefetch folder works.
Research has shown that clearing out the prefetch folder doesn’t work.
If you find some of these sites to be a bit questionable, why not see what Ryan Myers has to say? He’s a developer on Microsoft Windows Client Performance Team. Read what he has to say about clearing out the prefetch folder in “Misinformation and the Prefetch Flag.”
XP systems have a Prefetch directory underneath the windows root directory, full of .pf files – these are lists of pages to load. The file names are generated from hashing the EXE to load – whenever you load the EXE, we hash, see if there’s a matching (exename)-(hash).pf file in the prefetch directory, and if so we load those pages. (If it doesn’t exist, we track what pages it loads, create that file, and pick a handful of them to save to it.) So, first off, it is a bad idea to periodically clean out that folder as some tech sites suggest. For one thing, XP will just re-create that data anyways; secondly, it trims the files anyways if there’s ever more than 128 of them so that it doesn’t needlessly consume space. So not only is deleting the directory totally unnecessary, but you’re also putting a temporary dent in your PC’s performance. (emphasis by Ryan Myers)
Still not convinced? Check out what Microsoft has to say.
The prefetch folder is self-maintaining, and there’s no need to delete it or empty its contents. If you empty the folder, Windows and your programs will take longer to open the next time you turn on your computer.
How does Prefetch help?
Windows XP doesn’t have human intuition. Mark Russinovich and David Solomon explain in their article. However, it does have Windows XP Cache Manager monitoring page faults. Hard page faults (needs reading from the disk) and soft faults (already in memory) that happen during boot and application startup. By default, the first two minutes of boot process is traced. This is also true for the 60 seconds after all Win32 services are done initializing. Or, 30 seconds after the user’s shell starts. It can also be whichever of these three happens first.
The Cache Manager is given a chance to prefetch every time the system boots up or an application is called for. Cache Manager then checks if a trace already exists. There’s more to the process than this, but explaining gets a little more complicated.
Essentially though, prefetching improves performance by gathering all or prefetching data from a directory or from a file all in one go before going on to the next one. To describe the process simply, think of prefetching as doing laundry. You pick up all the laundry from the laundry basket in one room before moving on to the next room’s laundry basket. Not having to pick up the laundry from various places in the room saves you a lot of time.
Microsoft observed that “picking up scattered laundry” so to speak, delayed boot and application times. So, the “laundry basket” was created to speed things up.
One argument people have for clearing out the Prefetch folder is defragmentation. They argue that these are also data files and as such are prone to defragmentation leading to a slowdown.
The Task Scheduler, every time the system idles or every three days, categorizes a list of all files and directories in the order of referencing during boot or application start up. This is kept in \Windows\Prefech\Layout.ini. The system defragmenter is launched to defrag based on file contents instead of doing a full scale defragmentation. The defragmenter looks for a chunk of space large enough to hold all the listed files and directories and moves them all there so that they are next to each other; thus easy access is promoted.
The prefetch folder is also self maintaining. It keeps to 128 entries and will clean itself when necessary.
There are many controversial tips and tricks out there. Cleaning out the Prefetch folder is definitely one of them. You may end up causing your hard disk even more strain by clearing your prefetch folder; your disk works to delete the entries only to write them again when you call them up (and you surely will) again.
If it ain’t broke, don’t fix it!