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:

  1. if disk not ssd, it's better if write serially, seek files.. seek killer i/o performance.
  2. the disks typically writes in sector sizes. sector sizes 512b or 4k (newer disks). try write data 1 sector @ time.
  3. bunching i/o faster multiple small i/os. simple reason processor on disk has smaller queue flush.
  4. 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.
  5. if you're doing i/o management, make sure don't double-buffer os page cache. o_direct this.
  6. use non-blocking, if reliability isn't issue. o_nonblock

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -