I'm looking to maximise performance of my hard drive by enabling write caching. I understand the risks in doing this, but believe them to be insignificant for how I will use it.
On the HD Properties tab in Windows, the last two options are a bit confusing:
Enable write caching on device
- ok, but how does that work in conjunction with the previous option? Does it override windows caching or work alongside it?
Turn off Windows write cache
- Ok, but why would I do this. And if I tick this box then the Better Performance option is still selected, contradicting itself.
Can someone help clear up exactly what these flags do and how they affect/rely on each other.
The second option isn't "windows caching" as you say, but the inhibition of the "flush" system call:
Turn off Windows write cache buffer flushing
This option would disable the flush command called by some application (and on machine shutdown), whose purpose is to effectively write disk cache to the disk.
It won't disable the write cache.
You can try to enable this option, at the risk of data loss, but depending on your context, the performance gain may be not noticeable.
Really the difference is highlighted in the Removal Policies. This looks like a similar question to: https://superuser.com/questions/215372/what-does-write-cache-buffer-flushing-mean
You have to understand how data is written to disk.
You have a couple of subsystems involved in the process of writing the data from the process to physical disk.
Usually the processes are asking the kernel (the OS) to write something to disk. Also the kernel itself can write some data to disk e.g. as a swap-out operation.
The memory pages that need to be written to disk is kept in a region in physical memory called file system cache and are called dirty pages, and it will be written to disk if one of the conditions is true:
Now the data will go to disk, but the disk subsystem has 2 components that are important of this explanation:
Modern disk controllers have some memory modules that are called disk buffer. If this is activated, data flushed to disk subsystem will get written into the disk buffer and the operation will be considered completed by OS and programs, but the data is not yet on disk. The problem with this is that if you reboot your machine you have very high chances to lose data. You might not notice this until you have a filesystem corruption, or database corruption.
Here are some reasons why processes or OS needs to flush the data to disk:
The current configuration is the best trade off between performance and safety, unless you have an UPS (uninterruptible power supply).