RAMdisk slower than disk?

后端 未结 5 522
天命终不由人
天命终不由人 2020-12-11 15:33

A python program I created is IO bounded. The majority of the time (over 90%) is spent in a single loop which repeats ~10,000 times. In this loop, ~100KB data is generated a

5条回答
  •  被撕碎了的回忆
    2020-12-11 16:04

    Your operating system is almost certainly buffering/caching disk writes already. It's not surprising the RAM disk is so close in performance.

    Without knowing exactly what you're writing or how, we can only offer general suggestions. Some ideas:

    • If you have 2 GB RAM you probably have a decent processor, so you could write this data to a filesystem that has compression. That would trade I/O operations for CPU time, assuming your data is amenable to that.

    • If you're doing many small writes, combine them to write larger pieces at once. (Can we see the source code?)

    • Are you removing the 100 KB file after use? If you don't need it, then delete it. Otherwise the OS may be forced to flush it to disk.

提交回复
热议问题