-
Notifications
You must be signed in to change notification settings - Fork 153
FAST_POLL support and switch to rustix #337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
|
One benefit of the rustix-uring crate is that if a feature isn't added yet, there are still ways to use the raw API to get around it. For example, neither this crate nor the rustix-uring have a proper API for use std::os::fd::AsFd;
use rustix::io_uring as sys;
const fn cast_ptr<T>(n: &T) -> *const T {
n
}
fn execute<Fd: AsFd>(
fd: Fd, opcode: sys::IoringRegisterOp, arg: *const core::ffi::c_void, len: u32,
) -> io::Result<()> {
unsafe {
sys::io_uring_register(fd.as_fd(), opcode, arg, len)?;
}
Ok(())
}
let mut arg = sys::io_uring_napi::default();
arg.busy_poll_to = 1 << 20;
arg.prefer_busy_poll = 1;
#[allow(clippy::expect_used)]
execute(
&self.io_uring,
sys::IoringRegisterOp::RegisterNapi,
cast_ptr::<sys::io_uring_napi>(&arg).cast(),
1,
)
.expect("failed to register napi"); This is because the bindings themselves are a separate public API of the rustix crate, which are updated more frequently. |
@utkarshgupta137 You can use this crate with rustix or any of your own linux api crates. I thought let io_uring: io_uring::IoUring = ...;
rustix::io_uring::io_uring_register(
io_uring.as_fd(),
sys::IoringRegisterOp::RegisterNapi,
&arg,
1
).unwrap(); And, it would be even better if you are willing to open a PR for napi. |
Yeah, I was planning to add a PR for missing features. But I'm still iterating over the setup I want to use for my application, so it is better for me to do things manually now, before I try to write a proper API in the library. |
@quininer 1. I've misunderstood. 2. It'd make code much cleaner. |
Uh oh!
There was an error while loading. Please reload this page.
Howdy!
2 things are proposed in this issue:
Thanks,
Alex <3
PS: FAST_POLL is monoio's secret sauce for performance
The text was updated successfully, but these errors were encountered: