O_DIRECT can have a lot of benefits. However, while O_DIRECT may be simple to use by itself, the other design and implementation requirements that are indirectly dragged along are not trivial by any means. Consequently, you should not be using O_DIRECT unless you can manage the substantial indirect overhead in implementation. It turns off a lot of OS features most developers take for granted.
It turns off a lot of OS features most developers take for granted.
Yeah, like OS buffering. What else?
To use O_DIRECT effectively in Linux, at a minimum you need to write a buffer cache that is both fast and adaptive to workloads with proper cache replacement schedulers (no LRU crap), you need to write a complete I/O scheduler replacement (e.g. using io_submit and related interfaces) which is not portable at all, and you need to stop using almost all file system APIs (it interferes with the I/O scheduling bypass).
O_DIRECT is easy to use for very narrow cases. Taking advantage of it for anything slightly complicated in terms of file I/O usage and you bite off a lot more low-level implementation or the performance will actually be worse.