What posix_fadvise() args for sequential file write?

前端 未结 3 1517
不知归路
不知归路 2021-01-30 14:55

I am working on an application which does sequentially write a large file (and does not read at all), and I would like to use posix_fadvise() to optimize the filesy

3条回答
  •  醉梦人生
    2021-01-30 15:43

    As far as writes go I think that you can just rely on the OSes disk IO scheduler to do the right thing.

    You should keep in mind that while posix_fadvise is there specifically to give the kernel hints about future file usage patterns the kernel also has other data to help it out.

    If you don't open the file for reading then it would only need to read blocks in when they were partially written. If you were to truncate the file to 0 then it doesn't even have to do that (you said that you were overwriting).

提交回复
热议问题