Repository navigation
feat: add io_uring buffer registration for READ_FIXED/WRITE_FIXED ops - #3035
Merged
Merged
Conversation
…rations Register page-aligned buffers with io_uring via IORING_REGISTER_BUFFERS, enabling READ_FIXED and WRITE_FIXED opcodes that eliminate per-SQE get_user_pages() overhead. This reduces kernel-side memory mapping cost for high-throughput sequential I/O. Key components: - RegisteredBufferGroup: manages page-aligned buffer allocation, kernel registration, lock-free checkout/return via atomic bitset - submit_read_fixed_batch/submit_write_fixed_batch: batch SQE helpers for the new fixed-buffer opcodes - IoUringReader/IoUringWriter: transparently use WRITE_FIXED/READ_FIXED when registered buffers are available, falling back to regular ops - IoUringConfig gains register_buffers and registered_buffer_count fields - Full stub module for non-Linux platforms (returns None/Unsupported)
- Allow mut_from_ref on as_mut_slice (unsafe interior mutability) - Use io::Error::other() instead of io::Error::new(ErrorKind::Other) - Use enumerate().take(n) instead of needless range loops
Change as_mut_ptr() and as_mut_slice() to take &mut self instead of &self, properly encoding exclusive access at the type level. Removes the #[allow(clippy::mut_from_ref)] workaround.
oferchen
force-pushed
the
feature/iouring-buffer-registration
branch
from
March 28, 2026 17:24
d1aa146 to
cf932b2
Compare
oferchen
added a commit
that referenced
this pull request
May 1, 2026
…#3035) * feat: add io_uring buffer registration for READ_FIXED/WRITE_FIXED operations Register page-aligned buffers with io_uring via IORING_REGISTER_BUFFERS, enabling READ_FIXED and WRITE_FIXED opcodes that eliminate per-SQE get_user_pages() overhead. This reduces kernel-side memory mapping cost for high-throughput sequential I/O. Key components: - RegisteredBufferGroup: manages page-aligned buffer allocation, kernel registration, lock-free checkout/return via atomic bitset - submit_read_fixed_batch/submit_write_fixed_batch: batch SQE helpers for the new fixed-buffer opcodes - IoUringReader/IoUringWriter: transparently use WRITE_FIXED/READ_FIXED when registered buffers are available, falling back to regular ops - IoUringConfig gains register_buffers and registered_buffer_count fields - Full stub module for non-Linux platforms (returns None/Unsupported) * fix: resolve clippy warnings in registered_buffers - Allow mut_from_ref on as_mut_slice (unsafe interior mutability) - Use io::Error::other() instead of io::Error::new(ErrorKind::Other) - Use enumerate().take(n) instead of needless range loops * fix: add missing register_buffers fields to IoUringConfig test literals * fix: replace needless return with unit value in match arms * refactor: require &mut self for RegisteredBufferSlot mutable access Change as_mut_ptr() and as_mut_slice() to take &mut self instead of &self, properly encoding exclusive access at the type level. Removes the #[allow(clippy::mut_from_ref)] workaround. * fix: declare slot variables as mut for as_mut_ptr calls * fix: use if-let instead of single-pattern match for clippy
oferchen
added a commit
that referenced
this pull request
May 5, 2026
…#3035) * feat: add io_uring buffer registration for READ_FIXED/WRITE_FIXED operations Register page-aligned buffers with io_uring via IORING_REGISTER_BUFFERS, enabling READ_FIXED and WRITE_FIXED opcodes that eliminate per-SQE get_user_pages() overhead. This reduces kernel-side memory mapping cost for high-throughput sequential I/O. Key components: - RegisteredBufferGroup: manages page-aligned buffer allocation, kernel registration, lock-free checkout/return via atomic bitset - submit_read_fixed_batch/submit_write_fixed_batch: batch SQE helpers for the new fixed-buffer opcodes - IoUringReader/IoUringWriter: transparently use WRITE_FIXED/READ_FIXED when registered buffers are available, falling back to regular ops - IoUringConfig gains register_buffers and registered_buffer_count fields - Full stub module for non-Linux platforms (returns None/Unsupported) * fix: resolve clippy warnings in registered_buffers - Allow mut_from_ref on as_mut_slice (unsafe interior mutability) - Use io::Error::other() instead of io::Error::new(ErrorKind::Other) - Use enumerate().take(n) instead of needless range loops * fix: add missing register_buffers fields to IoUringConfig test literals * fix: replace needless return with unit value in match arms * refactor: require &mut self for RegisteredBufferSlot mutable access Change as_mut_ptr() and as_mut_slice() to take &mut self instead of &self, properly encoding exclusive access at the type level. Removes the #[allow(clippy::mut_from_ref)] workaround. * fix: declare slot variables as mut for as_mut_ptr calls * fix: use if-let instead of single-pattern match for clippy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
RegisteredBufferGrouptype that allocates page-aligned buffers and registers them with io_uring viaIORING_REGISTER_BUFFERSfor zero-copy fixed-buffer I/Osubmit_read_fixed_batchandsubmit_write_fixed_batchhelpers forIORING_OP_READ_FIXED/IORING_OP_WRITE_FIXEDSQE submissionIoUringReaderandIoUringWriter- they transparently use fixed-buffer ops when available, falling back to regularRead/Writeopsregister_buffersandregistered_buffer_countfields toIoUringConfig(enabled by default)None/UnsupportedDesign decisions
std::alloc::allocwithLayoutaligned tosysconf(_SC_PAGESIZE)for optimal DMAAtomicU64words) for buffer slot managementIORING_REGISTER_BUFFERSIORING_OP_READ/IORING_OP_WRITERegisteredBufferSlotInfo) avoids lifetime complications when passing buffer metadata into batch functionsTest plan
page_size_is_positive_and_power_of_two- verifies system page size detectionregistered_buffer_group_rejects_zero_count/size- validates input boundsregistered_buffer_group_create_and_checkout- tests full lifecycle (create, checkout all, exhaust, return, re-acquire)buffer_slot_read_write_memory- verifies buffer memory read/write correctnessread_fixed_write_fixed_roundtrip- end-to-end ReadFixed/WriteFixed batch testtest_registered_buffer_group_via_writer/reader- writer and reader with registered bufferstest_registered_buffer_write_read_roundtrip- full write-then-read cycletest_registered_buffer_disabled_still_works- verifies fallback when registration is disabledtry_newreturns None,newreturns Unsupported