Hitting Peak File IO Performance with Zig

https://news.ycombinator.com/rss Hits: 19
Summary

Intro This post goes through how to maximize file IO performance on linux using zig with io_uring. All code related to this post can be found in this repo. a) Benchmark We are comparing fio and the zig code which can be found here. test system We are using a machine with: ubuntu 24.04 (6.14 kernel, HWE). kernel parameter nvme.poll_queues=16. "datacenter" NVMe SSD without any RAID. 756 GB of RAM. This amount of RAM should be irrelevant for this test. Since we are using direct_io hence there is no caching for the file. Ryzen EPYC CPU with 32 cores (64 threads). CPU should be mostly irrelevant for this test since we are using only one thread. fio config [global] direct=1 bs=512K rw=write ioengine=io_uring iodepth=64 size=16g hipri=1 fixedbufs=1 registerfiles=0 sqthread_poll=1 numjobs=1 [job0] filename=testfile Just changing rw=write to rw=read to do the read benchmark. zig code config The example does 64 512KB sequential reads at a time, same as the fio configuration. It also writes/reads the entire 16GB file same as fio. The underlying library uses the exact same features as configured in the fio config as well. Zig code also uses a single thread same as fio. benchmark numbers The result I get from fio is 4.083 GB/s write, and 7.33 GB/s read. Not including more detailed statistics that fio gives since the benchmark script doesn't have those. The result for the diorw example in zig is 3.802 GB/s write, and 6.996 GB/s read. The zig code is a bit slower than fio but it manages to hit expected numbers for the SSD. Also the fio run= timing exactly (to the millisecond) matches the zig code's timings so there might be some difference in bandwidth measurement. b) Implementation Most of the implementation follows concepts found in glommio which is a similar library written in Rust. io_uring usage follows the io_uring document. 1) How to use io_uring for file IO In my last blog post I benchmarked different io_uring parameters using fio to find which parameters gave a significan...

First seen: 2025-09-07 04:38

Last seen: 2025-09-07 22:41