use io_uring fixed file indices to bypass file descriptor table lookups in LinuxIo #1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Register SSTable (and other long-lived) file descriptors into io_uring's fixed file table, so the kernel can skip fd table lookups and refcount churn on every SQE.
Background
io_uring supports pre-registering a set of fds via
IORING_REGISTER_FILES/IORING_REGISTER_FILES_UPDATE. SQEs can then reference them by slot index (types::Fixed(slot)) instead of by fd (types::Fd(fd)), which avoids a file table lookup and atomic refcount bump/drop on every operation.This is entirely a
LinuxIoimplementation detail - theIotrait andVirtualIoneed no changes.Implementation
New fields on
LinuxIoConstruction
max_fixed_files: u32parameter toLinuxIo::new-1placeholder fds viaIORING_REGISTER_FILESfixed_filesis initialized asvec![None; max_fixed_files as usize]open()handleintopending_opensafter a successful SQE pushpoll()pending_opens:Ok(fd), callregister_fixed(fd)to find a free slot and callIORING_REGISTER_FILES_UPDATEfor that slotpending_closes:fixed_filesandfd_to_slot, update the kernel table with-1for that slotclose()(handle, fd)intopending_closesafter a successful SQE pushSQE construction (read_at, write_at, fsync, fstat)
fd_to_slot.get(&fd):types::Fixed(slot)types::Fd(fd)Notes
types::Fdrather than erroringVirtualIorequires zero changes