As covered last week Linux I/O expert Jens Axboe has been taking a fresh pursuit of uncached buffered I/O for Linux. This “RWF_UNCACHED” work was originally started back in 2019 while a renewed effort around it is showing ~65% faster read/write performance and so far has been extended to work across EXT4, Btrfs, and XFS file-systems.
With good progress on his patches last week, this week he’s sent the series off to the mailing list for further review and collaboration. In the patch series Axboe sums things up elegantly for those not following the latest progress or unfamiliar with the prior uncached buffered IO work with the RWF_UNCACHED flag:
“Why do this, you may ask? The tldr is that device speeds are only getting faster, while reclaim is not. Doing normal buffered IO can be very unpredictable, and suck up a lot of resources on the reclaim side. This leads people to use O_DIRECT as a work-around, which has its own set of restrictions in terms of size, offset, and length of IO. It’s also inherently synchronous, and now you need async IO as well. While the latter isn’t necessarily a big problem as we have good options available there, it also should not be a requirement when all you want to do is read or write some data without caching.
Even on desktop type systems, a normal NVMe device can fill the entire page cache in seconds. On the big system I used for testing, there’s a lot more RAM, but also a lot more devices. As can be seen in some of the results in the following patches, you can still fill RAM in seconds even when there’s 1TB of it. Hence this problem isn’t solely a “big hyperscaler system” issue, it’s common across the board.”
But the real kicker are the easy wins with ~65% faster read and write performance while also having lower CPU usage.
“Performance results are in patch 8 for reads and patch 10 for writes, with the tldr being that I see about a 65% improvement in performance for both, with fully predictable IO times. CPU reduction is substantial as well, with no kswapd activity at all for reclaim when using uncached IO.
Using it from applications is trivial – just set RWF_UNCACHED for the read or write, using pwritev2(2) or preadv2(2). For io_uring, same thing, just set RWF_UNCACHED in sqe->rw_flags for a buffered read/write operation. And that’s it.”
Hopefully this uncached buffered I/O support manages to make it into the mainline Linux kernel soon.