By sgj |
Prefetch

Today we’ll take a look at the memory pre-fetching feature. This feature was introduced over 20 years ago in Windows XP. Does it still make sense to use it?

As we mentioned earlier, memory pre-fetching was introduced in Windows XP. How does it work?

Windows analyzes the programs that run with the system and creates special *.pf files in the \Windows\Prefetch folder.

These small files contain information about a given application and how often it is launched. PF files contain:

  • Program name (EXE file)
  • Path
  • Creation, modification, and access dates
  • Number of runs
  • Dates of most recent runs

Based on the PF files, the system preloads a given program into memory during startup.

Among the misconceptions about how this feature works, two are particularly common:

  • Applications are copied to the prefetch folder to load them faster
  • Deleting the contents of the prefetch folder will free up as much as several gigabytes of disk space

Neither of these is true. The first stems from what we mentioned earlier. PF files are not applications; they contain only information about launching applications.

The second, on the other hand, is a figment of someone’s imagination. Depending on the system version, the prefetch folder takes up anywhere from a few to over a dozen megabytes. Can it grow to uncontrollable sizes? No. This is because this feature has a hard limit on the number of PF files that can be created.  In XP-7 systems, the limit is 128 files; in newer systems, it is 1024.

We already know that this feature neither copies apps to a folder nor creates gigabytes of disk space. But is there any point in using it, and should we delete PF files?

One argument in favor of disabling this mechanism is that modern SSDs are fast enough that this mechanism isn’t necessary. Yes and no. Even an SSD can slow down in certain situations, and if you don’t normally notice a difference, there’s no point in changing anything. 

However, there is one situation where deleting these files can be beneficial. If you frequently install new programs, use them, then uninstall them and install new ones, certain issues may arise. The prefetch folder may still contain entries for applications that no longer exist. In that case, the system may take longer to boot up and use more RAM. This is due to unnecessary file searches. A similar situation may occur when PF files become corrupted...

What should you do in that case? The best solution is to delete the PF files from the prefetch folder. After the next system startup, things should return to normal, although the system may take a little longer than usual to boot at first.

If for some reason you want to disable prefetch, you must do so manually using the Registry Editor (regedit.exe). It’s best to back up your system before proceeding.

You must run the Registry Editor with administrator privileges. In the editor, locate the key 

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\PrefetchParameters

In it, we should see a value named EnablePrefetcher

EnablePrefetcher can take the following values:

0 - Disabled

1 - Enabled for applications

2 - Enabled for files loaded during system startup

3 - Enabled for applications and files loaded during system startup. This is the default option.

One argument in favor of disabling this feature is that SSDs are fast enough, and additional writes shorten the drive’s lifespan. While these arguments hold true in theory, in practice, a few extra writes won’t drastically shorten the drive’s lifespan. Performance, however, depends on many factors, so it’s best to run the tests yourself.