-
Notifications
You must be signed in to change notification settings - Fork 18
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
Consider returning Future instead of Result from Filesystem methods #3
Comments
This is an interesting idea, and I think it's worth looking into. I'm currently just beginning to learn the Futures / Tokio framework. I took a very brief stab at changing just one of the calls to have the client FS return a Future instead of the result, and not dispatching it onto a threadpool, and I ran into some problems:
If you've got some time and interest, then by all means, please take a shot at implementing it. I'd like to see it. I'm going to keep looking into it myself, because if nothing else it's an excuse to learn this new framework. |
Actually, I got motivated enough to take another stab at it myself and fixed the issues I was having. Experimental branch is here: https://github.com/wfraser/fuse-mt/tree/futures Would this be an improvement for you? This experimental code only adds futures for the four syscalls that the current code does on background threads (read, write, flush, fsync); I know for a network filesystem you'd really want all of them to be futures, and this is the direction I would ultimately take this. |
Certainly this is an improvement. I began mocking up a trait which used futures for everything and didn't need Boxed futures either - once I finish that, I'll let you know. BTW the way I imagine the Filesystem trait working in the long run is a layered system. Working from inside out this looks as:
|
Yep, I'm still iterating on my experimental branch, and one thing I'm not entirely sure of is who should own the executor: FuseMT or the client filesystem? I currently have FuseMT owning it, but I wonder if that design potentially limits filesystems from doing something... Another thing is FuseMT's original purpose of running I/O heavy tasks on a threadpool. This design gets rid of the threadpool and moves it out into the client filesystem (where the returned futures can be ones made using futures-cpupool). I wonder if this is the right decision, or if perhaps FuseMT should provide the ability to optionally do this itself. Finally, there's the issue of synchronization, which I'm punting on for now by only making the big 4 I/O heavy operations asynchronous. Ideally, all operations would be asynchronous, but then there's potentially the problem of having the operations get run out of order. For example: in a normal filesystem, if you issue an |
I think leaving threading decisions of IO heavy tasks to the implementer is the current thing to do. I also think that the for now the reactor should be owned by FuseMT. As for synchronization, I'm not sure but I think we will need more users of the library before we decide on what exactly to do there. |
Just noting: you could actually run the reactor in the main thread as well. The IO operation in Assuming this, we need to replace implementation of EDIT: Ok, apparently this was already discussed here zargony/fuse-rs#74. |
Currently all methods in the FilesystemMT return a Result indicating the response to the method call.
While it is true that all requests are currently processed concurrently using threading, it may be more ergonomic to make everything run on a reactor (from tokio-rs core crate) and change all methods to return Futures instead of Results.
In my case, I am trying to use async IO to perform network requests (I'm writing a network filesystem) and threading on the library level is not useful. Utilising futures-rs means that implementors can use whichever mechanism is more appropriate to them (whether that be disk IO on a thread pool or network requests on a reactor).
I'd be happy to prototype this in a fork and send a PR if you are open to it!
The text was updated successfully, but these errors were encountered: