-
Notifications
You must be signed in to change notification settings - Fork 156
driver: refactor the driver to be stored in a shared set of handles #196
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
Conversation
|
I still need to fix the tests. |
|
Might be a good idea to hide whitespace when reviewing. |
| .build() | ||
| }, | ||
| ) | ||
| CONTEXT.with(|x| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For many of these op constructors, I plan to have the weak handle in the socket object.
| self.inner.borrow_mut().uring.submit() | ||
| } | ||
|
|
||
| pub(crate) fn register_buffers( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to move a bunch of these methods into the Driver and do delegated calls here, but in another PR.
| // only used in tests rn | ||
| #[allow(unused)] | ||
| fn num_operations(&self) -> usize { | ||
| pub(super) fn num_operations(&self) -> usize { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice if things like this were exposed to the tracing tool, tokio console.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this is a good idea to expose eventually.
This opens up a lot of further cleanup opportunities, especially around shutdown logic. It also opens up the opportunity for us to eventually provide a public Handle API. More refactoring to come.
050282b to
140b505
Compare
|
I've fixed the tests and marked this and removed the draft label. |
|
Not as part of this PR, but perhaps a quick follow-on. What would you think about moving the definitions from all the mod.rs files into their own files? So the mod files are just lines of |
|
Please remind me, why does the tokio-uring/src/runtime/mod.rs Lines 55 to 57 in ca8887c
|
This is a really good idea. |
Because this spawn method is static and thus happens via the thread local context in tokio. |
But Tokio still adds it to this crate's runtime's localset because that localset is in some sense active, because it all happens in the context of calling rt.block_on(self.local.run_until(..))? |
|
Entering a LocalSet context (e.g run_until) sets thread locals within tokio to denote the "current" runtime, kinda like we now are with the drivers. |
|
Regarding the goal of this PR, I am trying to make it so that we don't need to orchestrate our entire shutdown logic around the thread locals rather than purely the CONTEXT thread local, which is slightly broken to begin with (I believe that there are currently issues around creating two runtimes at the same time). Now the CONTEXT behaves more like in tokio. When you enter a runtime context via This also allows us to have a bit more flexibility with things like sending ops between multiple runtimes as well, so you can now await ops created from another runtime. Part of the goal of this is to add new options around things like fixed or provided buffers. This potentially allows us to work towards things like transferring buffers between uring runtimes. More importantly however, it is a crucial first step towards having a handle to a uring runtime. |
This cleans up a few different pieces and is a followup change from #196.
This cleans up a few different pieces and is a followup change from #196.
#196 broke the ability to populate a collection of fixed buffers off-runtime and then have it registered inside a runtime. There is no need for the driver when a fixed buffer collection is populated. The driver comes in when registering and unregistering the buffers, and then as well, we don't currently need the collection to be affine to the driver. The driver always compares the pointer passed in to prevent unregistering the wrong buffers, so we can just grab the driver from the context. Change the doc examples to show and exercise off-runtime creation of `FixedBufPool` and `FixedBufRegistry`.
This opens up a lot of further cleanup opportunities, especially around shutdown logic. It also opens up the opportunity for us to eventually provide a public Handle API.
I am trying to make it so that we don't need to orchestrate our entire shutdown logic around the thread locals rather than purely the CONTEXT thread local, which is slightly broken to begin with (I believe that there are currently issues around creating two runtimes at the same time).
Now the CONTEXT behaves more like in tokio. When you enter a runtime context via block_on, we set the context. When we leave that call, we unset the context.
This also allows us to have a bit more flexibility with things like sending ops between multiple runtimes as well, so you can now in theory await ops created from another runtime.
Part of the goal of this is to add new options around things like fixed or provided buffers. This potentially allows us to work towards things like transferring buffers between uring runtimes.
More importantly however, it is a crucial first step towards having a handle to a uring runtime.
More refactoring to come.