There’s a famous Linus’ quote, saying that O_DIRECT is useless, or even hell.
If one has a super-strong demands for speed, really there is no scenario for a reasonable use of this flag for regular files in Linux?
Edit: What about “write-only” access to log files?
Streaming write throughput is much more deterministic with
O_DIRECTthan without. It’s a godsend.Compare the streaming write throughput you get from writing to a high-speed disk array’s block device (something like a theoretical hw capability) to the throughput you get to a file on a filesystem on that same array. Make sure you use a filesystem which has good streaming write performance (
xfsis one, some of the other modern ones may be as well). Then putO_DIRECTin and see what happens. Every kernel release + disk array I’ve evaluated has exhibited signficant differences (a much wider sd withoutO_DIRECTthan with).EDIT: to be fair, I’ve never compared
writeon anO_DIRECTfd withmmap/madvise.