Using FILE_FLAG_NO_BUFFERING will lead to a noticeable increase in speed?

A detailed description of the FILE_FLAG_NO_BUFFERING flag on MSDN has recently appeared and several Google search results on unbuffered I / O on Windows have been read.

http://msdn.microsoft.com/en-us/library/aa363858(v=vs.85).aspx

I wonder if it is really important to consider the unbuffered option in programming file I / O? Since many programs use the plain old C or C ++ iostream I / O stream, I had previously ignored the FILE_FLAG_NO_BUFFERING flag.

Suppose we are developing a photo editor program such as Picasa. If we implement unbuffered I / O, can the displayed display speed show a noticeable difference in ordinary users?

+6
performance file-io winapi
source share
2 answers

No, this flag is not for regular disk users. This is for programs such as databases, where they need to do their own file cache management for optimal performance. Although I'm sure that you could find situations where it will speed up your program, for the most part you will want to use the buffering provided by the OS, which is why it is there.

+7
source share

Oh Lord no. Using this flag, you make it much slower. It bypasses the file system cache, this wonderful piece of code that can guess with almost psychic accuracy that you will want to read sector N + 1 after reading N. And just preload it if it's cheap to get it.

This is especially bad for writing, so the option exists, you do not get lazy writebacks. This means that your program can only run as fast as it can burn a disc. Which is very, very slow. The advantage of the flag is that you can be sure that it was written. Helps implement updates for transactional disks that dbase operating systems take care of.

But try this for yourself to see the effect.

+11
source share

All Articles