c++ - Writing to hard disk more efficiently -
i'm writing streams of images hard disk using std::fstream. since hard disk drives have 32mb cache, more efficient create buffer accumulate image data 32mb , write disk, or efficient write every image onto disk?
the cache used read/write cache alleviate problems due queuing.... here experiences disks:
- if disk not ssd, it's better if write serially, seek files.. seek killer i/o performance.
- the disks typically writes in sector sizes. sector sizes 512b or 4k (newer disks). try write data 1 sector @ time.
- bunching i/o faster multiple small i/os. simple reason processor on disk has smaller queue flush.
- whatever can serve memory, serve. use disk if necessary. can modify/invalidate cache entry on write, depending on reliability policy. make sure don't swap, memory cache size must reasonable, begin with.
- if you're doing i/o management, make sure don't double-buffer os page cache. o_direct this.
- use non-blocking, if reliability isn't issue. o_nonblock
Comments
Post a Comment