Bienvenido! - Willkommen! - Welcome!

Bitácora Técnica de Tux&Cía., Santa Cruz de la Sierra, BO
Bitácora Central: Tux&Cía.
Bitácora de Información Avanzada: Tux&Cía.-Información
May the source be with you!

Wednesday, August 10, 2011

Prefetcher

The Prefetcher is a component of versions of Microsoft Windows starting with Windows XP.[1] It is a component of the Memory Manager that speeds up the Windows boot process, and shortens the amount of time it takes to start up programs. In Windows Vista, SuperFetch and ReadyBoost [2] extend upon the prefetcher and attempt to accelerate application and boot launch times respectively by monitoring and adapting to usage patterns over periods of time and loading the majority of the files and data needed by them into memory so that they can be accessed very quickly when needed.
When a Windows system boots, a large number of files need to be read into memory and processed. Often, this includes loading different segments of the same file at different times. As a result, a significant amount of time is spent opening and accessing files multiple times, where a single access would be more efficient. The prefetcher works by watching what code and data is accessed during the boot process (including a reading of the NTFS Master File Table), and recording a trace file of this activity. Future boots can then use the information recorded in this trace file to load code and data in a better fashion. The boot prefetcher will continue to watch for such activity until 30 seconds after the user's shell has started, or until 60 seconds after all services have finished initializing, or until 120 seconds after the system has booted, whichever elapses first. Application prefetching works in a similar fashion, but is instead localized to a single application's startup. Only the first 10 seconds of activity are monitored.[1]:458
The prefetcher stores its trace files in the "Prefetch" folder in the root Windows directory (typically \Windows\Prefetch). The name of the boot trace file is always NTOSBOOT-B00DFAAD.PF, and application trace files are a concatenation of the application's executable name, a hyphen, a hexadecimal representation of the hash of the path the file resides in, and a ".pf" extension. Applications that host other components (i.e. Microsoft Management Console or Dllhost) have the name of the loaded component included in the computed hash as well; this results in different trace files being created for each component.
Task Scheduler is the process responsible for parsing the trace data collected by the prefetcher and writing files to the prefetcher directory. As a result, the prefetcher will not operate correctly if the Task Scheduler service is not started.
An additional feature of Task Scheduler is its ability to interact with the Windows Disk Defragmenter. Every three days, when the machine is idle, a list of files and directories that are referenced during the boot process and application startups is created.[1]:461-462 This list is stored in Layout.ini in the Prefetch directory, and is subsequently passed to the Disk Defragmenter, instructing it to place all the files in sequential order on the physical hard drive, which will further improve startup performance, as Windows will spend less time waiting for the hard drive's heads to move to the relevant data. Alternatively, running "Defrag.exe %systemdrive% -b" from the command line forces a defragmentation of the prefetcher files without requiring a full defragmentation 
Configuration
The Prefetcher's configuration is stored in the Windows Registry at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\PrefetchParameters. The EnablePrefetcher value can set to be one of the following:[4]
  • 0 = Disabled
  • 1 = Application launch prefetching enabled
  • 2 = Boot prefetching enabled
  • 3 = Applaunch and Boot enabled (Optimal and Default).[4]
The recommended value is 3 [4].
Incorrect tweaking of the prefetcher The default prefetcher setting is to optimise the speed of boot time and application loading times. Values higher than 3 do not increase performance.[4] (Note that 2 is the default value on Windows 2003[5]). Changing the value to 2 will not make Windows boot faster.[4]
Often found on the Internet[6] is the "/prefetch:1" application tweak[7], which is a valid but nonetheless generally ineffective switch.[8] A second myth is that the user should delete the prefetch folder contents to speed up the computer. If this is done, Windows will need to re-create all the prefetch files again, thereby slowing down Windows during boot and program starts until the prefetch files are created—unless the prefetcher is disabled.[9][10]
Windows maintains no more than 128 entries in the Prefetch folder.

No comments: