views:

289

answers:

3

When CreateFile Function is called without the flag FILE_FLAG_NO_BUFFERING, what is the size of the inner buffer of operating system?

If my buffer size is larger than the inner buffer of Windows, can I fully use up the throughput of disk?

A: 

It likely varies from windows version to windows version, as well as depending on the amount of free RAM. Rather than relying on anything specific, you should simply do reads and writes with buffer sizes that work well for your application.

bdonlan
A: 

It depends how much RAM you have, and how the machine is configured. Servers are usually configured to privilege system cache. You could change that by altering the following registry key

[HKEY_LOCAL_MACHINE \System \CurrentControlSet \Control \Session Manager \Memory Management] LargeSystemCache

The SetSystemFileCacheSize function can be used to alter the cache size. However, from what I understand, setting the working set size is more of a hint to the operating system than a hard limit.

In regards to your second question, I'm not exactly sure what you mean. I don't see how the size of your buffer will affect throughput, but I'm sure someone will correct me if I'm wrong.

wkf
A: 

If you're using no-buffering, there really isn't a buffer for the I/O other than the one you gave to read/write. (This is excepting compressed files, which is a different ball of wax.)

The system cache is ignored in this case, which is why you're required (see MSDN) to be careful with alignment and the size of your I/O.

jrtipton