`

Description of the hard disk cache

 
阅读更多

转自: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 harddisk performance. 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.
  • 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 - 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 - 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 Write caching, 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 flushed write. 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 - 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 - 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 to enablePower Protected write cache. More Info MS KB Q811392MS 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 for performance" 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")

More Info MS KB Q324446
More Info Microsoft - Windows Confidential: The Power of Bugs

Related Configure IDE ATA hard disk for best performance

 

 

附:

Disk buffer

http://en.wikipedia.org/wiki/Disk_buffer

分享到:
评论

相关推荐

    Qemu-1.0.1 for windows

    'disk_image' is a raw hard disk image for IDE hard disk 0 Standard options: -h or -help display this help and exit -version display version information and exit -machine [type=]name[,prop[=value][,.....

    BURNINTEST--硬件检测工具

    - Disk space: 6 Meg of free hard disk space (plus an additional 10Meg to run the Disk test) - DirectX 9.0c or above software for 3D graphics and video tests (plus working DirectX drivers for your ...

    uhdd.sys源码

    cache Data from the disk NOT data still in cache can then be compared to the original output 2 NO Warranties XMGR RDISK and UIDE are offered at no cost "as is" "use at your own...

    qemu-0.13.0(编译过全处理器支持)

    QEmu虚拟机 做嵌入式开发的朋友试试 调试内核很方便 ...usage: qemu [options] [disk_image] 'disk_image' is a raw hard disk image for IDE hard ... force hard disk 0 physical geometry and the optional BIOS ...

    Solaris 10 System Administration Essentials

    8.1 Hard Disk Drive 197 8.2 Disk Terminology 199 8.3 Disk Device Naming Conventions 200 8.3.1 Specifying the Disk Subdirectory in Commands 202 8.4 Overview of Disk Management 202 8.4.1 Device Driver ...

    计算机英语专业词组.doc

    24. **硬盘(Hard Disk)**:非易失性磁存储设备,用于长期存储大量数据。 25. **代码转换(Code Conversion)**:将一种编码形式转换为另一种编码形式的过程。 26. **程序控制I/O(Programmed I/O)**:通过CPU...

    让Django的BooleanField支持字符串形式的输入方式

    'cpu', 'hard_disk', 'machine_os', 'idc', 'machine_group') ``` 2. **自定义字段设置排序**:在xadmin中,还可以通过定义自定义方法来实现对特定字段的排序。 ```python def identity(self, ext): return ...

Global site tag (gtag.js) - Google Analytics