What does "Write cache buffer flushing" mean

12

4

As in the Windows 7 Disk Policy Options:

[x] Enable Write Caching on the device
[ ] Turn off Windows write-cache buffer flushing on the device 

Is the first the cache on the physical disk, and the second the windows cache?

(I've googled, but didn't find a clear answer).

peterchen

Posted 2010-11-26T16:13:59.093

Reputation: 1 602

Answers

12

See "more information" section from http://support.microsoft.com/kb/332023:

Many disk devices provide enhanced performance through the use of an onboard cache, which provides read-ahead caching for data that is being read from the disk, and write-behind caching (or delayed writes or "lazy" writes) for data that is being written to disk. In some cases, it is important for data to be written to the physical disk immediately, and not retained in the disk's onboard write cache to be written later during an otherwise idle moment. This prevents loss or corruption of this data if the disk or controller (wherever the write cache is implemented) suddenly loses power

Write caching improves disk performance greatly, so leave it on for internal hard drives.

Windows turns write caching Off for flash drives and other usb hard drives by default, normally you do not have to ever modify these settings, Windows takes care of it for you.

Moab

Posted 2010-11-26T16:13:59.093

Reputation: 54 203

1This answer doesn't help me understand the difference between the two settings. If you flush the cache on every write, then you are not caching - in what way is write caching enabled (first check box)? It seems more likely that flushing occurs periodically when the second check box is disabled, or something similar. – Sam Brightman – 2015-09-20T11:31:47.493

3@SamBrightman: as much as I understand: The first setting enables the windows cache - if an applications writes to a file, it's not immediately passed on to the disk. An application may call "flush" to force things to be written physically. The second option says: when the application says "flush", Windows will still flush its own cache to the device, but will not tell the device to flush its own internal cache. This neuters the "flush" command (as the application thinks data is safe on disk). Acceptable only if data permanence is not a priority. – peterchen – 2015-09-21T10:14:57.217

5as Moab said. The only reason you may want to consider turning off Write Caching on internal hard disks is if you frequently experience brown-outs or black-outs. but if that is the case then i recommend you invest in a decent UPS and leave write caching on – Xantec – 2010-11-26T16:31:18.877

1Thanks for the link! If I understand it correctly, it means "don't flush even if the software says so". I was mostly curious about the second option, testing build speeds on SSD vs. HDD. Power grid problems are rarity-rare here indeed pat-pats german engineering. – peterchen – 2010-11-28T09:10:37.750

2

I always turn write-behind caching off, all the time, every time. It was a bad idea from the start. I explain it this way: If you click "Save" on your word processing document, and the power fails, with write-behind caching off, your document will not be saved (until autosave kicks in). Turning off write-behind caching forces it to actually write your file to the disk when you click save. The same applies to power outages, BSOD's, program crashes, etc.

CodeLurker

Posted 2010-11-26T16:13:59.093

Reputation: 21

1To round you answer out perhaps you could include how you disable it. Also cite some sources that back up your position. – slm – 2013-01-07T04:26:54.617

3But why does this make a difference? You have precisely the same problem if the power goes out before you click "Save" at all. – David Schwartz – 2013-02-03T00:30:38.807

@DavidSchwartz, the difference is that with caching off, the files is written to disk as soon as you click [Save], so if the power goes out a second later, the file is still there, but with it on, the file is may not be written for a few seconds or minutes, during which time the power could go out, and the file would be lost. – Synetech – 2013-09-16T18:44:51.500

1@CodeLurker, the performance benefits of caching are enough that it is generally worth the rare risk of power loss. Obviously the circumstances will dictate whether it should be used or not such whether power is reliable or not, what types of files are predominantly used, and so on. – Synetech – 2013-09-16T18:46:29.137

2@Synetech That's basically no difference. There's a window in which you can lose data either way, and most of that window is before you click "Save". – David Schwartz – 2013-09-16T19:54:52.737

4You could also lose your data by getting crushed by a falling asteroid a split second before clicking [Save]. By your reckoning, you may as well not even bother using a computer at all since it is inevitable to lose your data. ◔_◔ – Synetech – 2013-09-17T13:52:30.980

0

Based on an Old New Thing blog post it sounds like the first one is OS caching and the second one is an override for disk internal caching during flush only.

For normal writes with no flush, the disk internal cache will be used regardless of the second setting. However, for sync/flush events the default behaviour is to ensure that flushing the OS cache actually gets the data onto the media: tell the drive explicitly flush the internal cache too.

It's not clear to me whether turning off the first setting would do this disk flush on every write, or even disable the on-disk cache as well as disabling the OS cache.

Sam Brightman

Posted 2010-11-26T16:13:59.093

Reputation: 540