http://www.microsoft.com/technet/te...technet/technetmag/issues/2007/03/VistaKernel
ReadyBoost
The speed of CPUs and memory are fast outpacing that of hard disks, so disks
are a common system performance bottleneck. Random disk I/O is especially
expensive because disk head seek times are on the order of 10
milliseconds-an eternity for today's 3GHz processors. While RAM is ideal for
caching disk data, it is relatively expensive. Flash memory, however, is
generally cheaper and can service random reads up to 10 times faster than a
typical hard disk. Windows Vista, therefore, includes a feature called
ReadyBoost to take advantage of flash memory storage devices by creating an
intermediate caching layer on them that logically sits between memory and
disks.
ReadyBoost consists of a service implemented in
%SystemRoot%\System32\Emdmgmt.dll that runs in a Service Host process, and a
volume filter driver, %SystemRoot%\System32\Drivers\Ecache.sys. (Emd is
short for External Memory Device, the working name for ReadyBoost during its
development.) When you insert a flash device like a USB key into a system,
the ReadyBoost service looks at the device to determine its performance
characteristics and stores the results of its test in
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\Currentversion\Emdmgmt,
seen in Figure 1.
Figure 1 ReadyBoost device test results in the registry (Click the image for
a smaller view)
Figure 1 ReadyBoost device test results in the registry (Click the image for
a larger view)
If you aren't already using a device for caching, and the new device is
between 256MB and 32GB in size, has a transfer rate of 2.5MB/s or higher for
random 4KB reads, and has a transfer rate of 1.75MB/s or higher for random
512KB writes, then ReadyBoost will ask if you'd like to dedicate up to 4GB
of the storage for disk caching. (Although ReadyBoost can use NTFS, it
limits the maximum cache size to 4GB to accommodate FAT32 limitations.) If
you agree, then the service creates a caching file named ReadyBoost.sfcache
in the root of the device and asks SuperFetch to prepopulate the cache in
the background.
After the ReadyBoost service initializes caching, the Ecache.sys device
driver intercepts all reads and writes to local hard disk volumes (C:\, for
example), and copies any data being written into the caching file that the
service created. Ecache.sys compresses data and typically achieves a 2:1
compression ratio so a 4GB cache file will usually contain 8GB of data. The
driver encrypts each block it writes using Advanced Encryption Standard
(AES) encryption with a randomly generated per-boot session key in order to
guarantee the privacy of the data in the cache if the device is removed from
the system.
When ReadyBoost sees random reads that can be satisfied from the cache, it
services them from there, but because hard disks have better sequential read
access than flash memory, it lets reads that are part of sequential access
patterns go directly to the disk even if the data is in the cache.
ReadyBoot
Windows Vista uses the same boot-time prefetching as Windows XP did if the
system has less than 512MB of memory, but if the system has 700MB or more of
RAM, it uses an in-RAM cache to optimize the boot process. The size of the
cache depends on the total RAM available, but is large enough to create a
reasonable cache and yet allow the system the memory it needs to boot
smoothly.
After every boot, the ReadyBoost service (the same service that implements
the ReadyBoost feature just described) uses idle CPU time to calculate a
boot-time caching plan for the next boot. It analyzes file trace information
from the five previous boots and identifies which files were accessed and
where they are located on disk. It stores the processed traces in
%SystemRoot%\Prefetch\Readyboot as .fx files and saves the caching plan
under HKLM\System\CurrentControlSet\Services\Ecache\Parameters in REG_BINARY
values named for internal disk volumes they refer to.
The cache is implemented by the same device driver that implements
ReadyBoost caching (Ecache.sys), but the cache's population is guided by the
ReadyBoost service as the system boots. While the boot cache is compressed
like the ReadyBoost cache, another difference between ReadyBoost and
ReadyBoot cache management is that while in ReadyBoot mode, other than the
ReadyBoost service's updates, the cache doesn't change to reflect data
that's read or written during the boot. The ReadyBoost service deletes the
cache 90 seconds after the start of the boot, or if other memory demands
warrant it, and records the cache's statistics in
HKLM\System\CurrentControlSet\Services\Ecache\Parameters\ReadyBootStats, as
shown in Figure 2. Microsoft performance tests show that ReadyBoot provides
performance improvements of about 20 percent over the legacy Windows XP
prefetcher.
Figure 2 ReadyBoot Performance statistics (Click the image for a smaller
view)
Figure 2 ReadyBoot Performance statistics (Click the image for a larger
view)