【转】Description of the hard disk cache
2011-01-13 19:27
246 查看
From:http://smallvoid.com/article/hard-disk-cache.html
The hard disk is extremely slow compared to physical memory (RAM), but provides lots of storage capacity. Disk caching can be used to speed up the harddiskperformance. The disk cache uses RAM to provide quick access to frequently accessed data.
There are different levels of disk caching:
Hard disk Cache - Cache is located on the hard disk device and works only with sectors. It allows continuous reading from the disk even if the transfer-bus is busy.
Disk controller Cache - Cache is located on the controller card and works only with sectors. It allows reading from disk without using the transfer-bus to contact the hard disk.
Operating System Cache - Using RAM as hard disk cache and works on a file level. It allows file access without using the system-bus to contact the disk controller.
Win9x/WinMe : System File Cache
WinNT+ : System File Cache
Vista Readyboost - Cache is placed on high speed USB flash drives, which allows faster seek times and higher constant transfer rate than the HDD. Can deliver a very large and fast hard disk cache, though still slower than RAM.
There are usually two types of disk caching:
Read Cache[/b] - Allows the hard disk to read data ahead in the background, so the application doesn't have to block while waiting for the data to be read, but gets the data delivered from the cache instead.
Write Cache[/b] - Allows the hard disk to lazy write data in the background, so the application doesn't have to block while waiting for the data to be written, but enters the cache where it is later written to the hard disk.
How does write caching work?
Disk caching greatly improves disk performance, but there is a drawback to Writecaching, as anything written to the cache, which haven't been flushed to the disk will be lost when the power is lost. Most applications are aware of this behavior, and the operating system provides the ability to perform a direct write or flushedwrite. Write flushing means that the application will wait for the data to be written to disk before continuing, instead of just writing to the cache which completes right away.
Windows 3.11 had a flaw in its flush operation, so it actually just performed a lazy write to the cache when an application performed a flushed write. Several applications was created which was littered with flushed writes, because it performed so well. These applications performed miserable when used on Windows 95, which didn't have this flaw when performing flushed write, and naturally was much slower than just writing to the cache. One could activate the old buggy behavior by with the option to "Disable Synchronous Buffer Commits", which was hidden away in the troubleshooting section.
Later as server environments have become more and more stable with duplicate power supplies and UPS equipment, then the idea of actually ignoring the flush request has become a wish for those where high disk performance is critical. The Windows operating system can convert the following requests to normal I/O requests so the cache buffers are not flushed:
Write Through[/b] - Performs a write to disk without using the cache. Activated by calling the Windows API WriteFile() with FILE_FLAG_WRITE_THROUGH. Sends a Forced Unit Access (FUA) command to the storage device.
Flush Buffers[/b] - Tells the disk to flush everything it has in cache. Activated by calling FlushFileBuffers(). Sends a Synchronize Cache (SCSI) or Flush Cache (IDE/ATAPI) command to the storage device.
When to enable write caching?
The promise of increased performance is always nice, but when the price is the risk of dataloss, then one should be very carefull with changing the behavior of these disk requests.
It is not recommended to enable write caching on standard desktop/laptop machine, which can shutdown unexpectedly or freeze/crash because of a software/hardware error.
It is also not recommended to enable write caching when running a Database Management System (DBMS), as these requests are used to create stable commit checkpoints before beginning on a new transaction.
But if having a seperate harddisk for the pagefile or other temporary files, then there can be a performance boost with no cost.
How to configure write caching?
Windows 2000 SP3 / XP SP2 - Requires the utility Dskcache.exe[/b] to enablePower Protected[/b] write cache. More Info MS KB Q811392, MS KB Q332023
Windows 2003 / Vista - The option with the misleading name "Enable Advanced Performance", which can be found on the "Policies"-tab for each hard disk device in the "Device Manager" (Have to activate "Optimize forperformance" and "Enable write caching on the disk").
Windows 7 - The option is called "Turn off Windows write-cache buffer flushing on the device.", which can be found on the "Policies"-tab for each hard disk device in the "Device Manager" (Have to activate "Enable write caching on the device")
The hard disk is extremely slow compared to physical memory (RAM), but provides lots of storage capacity. Disk caching can be used to speed up the harddiskperformance. The disk cache uses RAM to provide quick access to frequently accessed data.
There are different levels of disk caching:
Hard disk Cache - Cache is located on the hard disk device and works only with sectors. It allows continuous reading from the disk even if the transfer-bus is busy.
Disk controller Cache - Cache is located on the controller card and works only with sectors. It allows reading from disk without using the transfer-bus to contact the hard disk.
Operating System Cache - Using RAM as hard disk cache and works on a file level. It allows file access without using the system-bus to contact the disk controller.
Win9x/WinMe : System File Cache
WinNT+ : System File Cache
Vista Readyboost - Cache is placed on high speed USB flash drives, which allows faster seek times and higher constant transfer rate than the HDD. Can deliver a very large and fast hard disk cache, though still slower than RAM.
There are usually two types of disk caching:
Read Cache[/b] - Allows the hard disk to read data ahead in the background, so the application doesn't have to block while waiting for the data to be read, but gets the data delivered from the cache instead.
Write Cache[/b] - Allows the hard disk to lazy write data in the background, so the application doesn't have to block while waiting for the data to be written, but enters the cache where it is later written to the hard disk.
How does write caching work?
Disk caching greatly improves disk performance, but there is a drawback to Writecaching, as anything written to the cache, which haven't been flushed to the disk will be lost when the power is lost. Most applications are aware of this behavior, and the operating system provides the ability to perform a direct write or flushedwrite. Write flushing means that the application will wait for the data to be written to disk before continuing, instead of just writing to the cache which completes right away.
Windows 3.11 had a flaw in its flush operation, so it actually just performed a lazy write to the cache when an application performed a flushed write. Several applications was created which was littered with flushed writes, because it performed so well. These applications performed miserable when used on Windows 95, which didn't have this flaw when performing flushed write, and naturally was much slower than just writing to the cache. One could activate the old buggy behavior by with the option to "Disable Synchronous Buffer Commits", which was hidden away in the troubleshooting section.
Later as server environments have become more and more stable with duplicate power supplies and UPS equipment, then the idea of actually ignoring the flush request has become a wish for those where high disk performance is critical. The Windows operating system can convert the following requests to normal I/O requests so the cache buffers are not flushed:
Write Through[/b] - Performs a write to disk without using the cache. Activated by calling the Windows API WriteFile() with FILE_FLAG_WRITE_THROUGH. Sends a Forced Unit Access (FUA) command to the storage device.
Flush Buffers[/b] - Tells the disk to flush everything it has in cache. Activated by calling FlushFileBuffers(). Sends a Synchronize Cache (SCSI) or Flush Cache (IDE/ATAPI) command to the storage device.
When to enable write caching?
The promise of increased performance is always nice, but when the price is the risk of dataloss, then one should be very carefull with changing the behavior of these disk requests.
It is not recommended to enable write caching on standard desktop/laptop machine, which can shutdown unexpectedly or freeze/crash because of a software/hardware error.
It is also not recommended to enable write caching when running a Database Management System (DBMS), as these requests are used to create stable commit checkpoints before beginning on a new transaction.
But if having a seperate harddisk for the pagefile or other temporary files, then there can be a performance boost with no cost.
How to configure write caching?
Windows 2000 SP3 / XP SP2 - Requires the utility Dskcache.exe[/b] to enablePower Protected[/b] write cache. More Info MS KB Q811392, MS KB Q332023
Windows 2003 / Vista - The option with the misleading name "Enable Advanced Performance", which can be found on the "Policies"-tab for each hard disk device in the "Device Manager" (Have to activate "Optimize forperformance" and "Enable write caching on the disk").
Windows 7 - The option is called "Turn off Windows write-cache buffer flushing on the device.", which can be found on the "Policies"-tab for each hard disk device in the "Device Manager" (Have to activate "Enable write caching on the device")
相关文章推荐
- Hiding Data from Forensic Imagers – Using the Service Area of a Hard Disk Drive
- DownLoadManager[20530:228829] DiskImageCache: Could not resolve the absolute path of the old directory.
- the method of resolve the problem that easyuefi can not select other hard disk as a bootable disk
- Comparision Among The Access Speed Of Cache , Memory And Disk
- 12.Which is the correct description of a pinned buffer in the database buffer cache?
- What can we do in the CacheMetaData Method of Activity
- Description of the Windows Installer CleanUp Utility
- The ZALMAN ZM VE200 SATA hard disk caddy with DVD/HDD/FDD emulation
- Android import和export使用说明 及 export报错:jarlist.cache: Resource is out of sync with the file syst解决
- Description Resource Path Location Type Java compiler level does not match the version of the instal
- Description Resource Path Location Type Java compiler level does not match the version of the instal
- gem5: the trace of cache set and cache line write hit counters
- 【RefactoringCode】The description of the refactoring book
- Tomcat8启动报there was insufficient free space available after evicting expired cache entries - consider increasing the maximum size of the cache
- 解决eclipse的 Invalid project description. overlaps the location of another project: 问题
- consider increasing the maximum size of the cache
- The Elements of Cache Programming Style
- Description Resource Path Location Type Java compiler level does not match the version of the instal
- The content of element type "class" must match "(meta*,subselect?,cache?,synchronize*,comment?,tupli
- Description Resource Path Location Type The value of attribute "schema" associated with an element t