3 ms·
Out of curiosity, what would a correctly designed storage engine do to get better throughput than mmap()ing files?
by corysama 12y ago
Out of curiosity, what would a correctly designed storage engine do to get better throughput than mmap()ing files?
- jandrewrogers 12y agoOn Linux, you would use io_submit + O_DIRECT on a small number of large files allocated in large chunks. In short, you become the I/O scheduler and buffer manager instead of the operating system, while removing most of the implicit context switches. It does require much more code than mmap()-ing and fairly sophisticated code at that. If you are doing it well, 3-5x throughput improvement seems to be average upside in my experience, which is huge. The scheduler behind mmap() simply does not have enough context about the workload to make good paging decisions leading to a lot of suboptimal or wasted I/O, and this is magnified when the storage I/O is under pressure. In principle, if you write your own I/O scheduler you can always make sure that the optimal I/O operation is executed at the optimal time.