c++ - Are disk file operations faster if executed in parallel? -


consider there n files written disk (i.e. flushed file buffers). each file write small (relative hdd seek time) amount of data, e.g. 64kb, writefile, , call flushfilebuffers on file ensure data file flushed hard drive.

if write&flush files one-by-one sequentially, expect approximately takes time n*seektime + n*writetime, seektime time position hard drive head proper sector (which may take time of full disk rotation), , writetime time takes disk write sequentially 64kb of data. such one-by-one approach give os no room optimization because define sequence in files must flushed.

with support os performance improvement achieved rearranging order of file write&flushes taking account disk rotation (i.e. current position of head on disk) file operations rearranged start no rotation needed (i.e. nearest current position of disk head) , ending whom full rotation of disk needed.

the question is: operating system (windows in particular) provide such optimization? in other words, can performance improved running file write&flush operations in parallel in n threads, 1 thread per file? or cause re-positioning operations decreasing performance (as kind of context-switches hard drive)?

you should first ask yourself, , explain here, why need flush. want achieve not happens.

if want optimize application in such way access pattern on physical device results, make solution hardware dependent. appears optimization on test cases may achieve opposite effect in scenario. example, file fragmentation? raid disks? network file systems? ssd drives? concurrent accesses same disk other processes running on same machine?

the key making disk accesses fast buffering. don't defeat if don't absolutely need defeat it.


Comments