I have an application that reads large amount of data from the disk and also writes a lot. I'm trying to use direct io to improve the I/O performance.
Now I'm using libaio
to implement the asynchronous IO, both for read and write. The preliminary result shows improvement in reading stage but great drop in writing stage.
Then I used strace
to capture the run time behavior and here is the reading stage log(I have deleted some unrelated log):
8509 20:59:03.005920 io_submit(139876672323584, 16, {{pread, filedes:102, buf:0x7f36bf816000, nbytes:524288, offset:96468992}} <unfinished ...>
8509 20:59:03.007236 <... io_submit resumed> ) = 16 <0.000893>
and here is the writing stage log:
8098 20:47:40.219194 io_submit(140277578346496, 1, {{pwrite, filedes:116, str:"\177\362\215\264\252\360\240\306\377?\265\36/\215#%\304\0343\300\230\256\3550\374 k\316\v\225\327\""..., nbytes:524288, offset:24117248}}) = 1 <0.002457>
Generally the same io_submit
API takes various time. Even though submitting 16 read requests at one time, it's still faster than submitting 1 write request.
So is it right? How can I optimize my write stage?