-
Notifications
You must be signed in to change notification settings - Fork 34
RFC for async #238
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
base: main
Are you sure you want to change the base?
RFC for async #238
Conversation
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 just watched the video about Sans IO and honestly I still have no idea how the implementation will look like ...
But looking at https://github.com/bearcove/rc-zip I see that we will need to add more crates for each runtime - tokio, async-std/smol, monoio, sync, etc. Tokio is pretty much the standard for async but the idea of having to add a crate for every runtime looks scary to me.
For now maybe_async
looks most promising to me!
(This is not a final decision! We are discussing!)
The annoying thing about For sans-io, we don't need to add a crate for every runtime. We can provide a sync and a tokio crate, and if someone wants to use a different runtime they can wrap the core crate themselves. The wrapper can be really simple, namely just a loop over the parser. The reason that I plan on experimenting with writing a basic Sans I/O parser for Avro, just to see how it would look. |
Didn't they solve this by introducing two features (is_async and is_sync) and the macro generates separate module/function for each ? E.g. #[maybe_async]
async fn foo() {...} would generate |
Looking at the docs (specifically the last two codeblocks), it doesn't seem to rename the functions. |
https://crates.io/crates/synca - one more contender. I haven't explored it too much. |
That looks a lot better than |
I've pushed a (non-functional) prototype for parsing with state machines. The most interesting thing about this prototype is the use of a "command" tape and a "output" tape. The implementation is far from perfect and there is a lot that could be improved. For one, the I do think it gives a good idea of what it would be like to have the core be state machines, wrapped in async and sync wrappers. I currently only have a sync wrapper, but I'll start on an async wrapper just using the Note: I've not implemented converting the schema to a "command" tape. Implementing it is easy, implementing it so that the tape is compact is a bit more complicated. I've also not implemented decoding the "output" tape to a |
I've added the async implementation. |
I did not check clippy before pushing, as it doesn't function anyway (too many |
I've done some small refactoring in the state machine POC. The logic of the Object Container file format is now moved to a state machine, making the sync and async readers really simple. I've also added proper EoF handling. |
I also did an attempt at making a SyncA POC, but don't yet known what to do about the iterators |
@martin-g if you like the statemachine approach, I can start work on making it a proper PR (including stuff like tests and handling edgecases). If you'd like to see a POC with SyncA first, that's possible too. |
Thanks for all your work on this topic! Yes, I would to try with SyncA too! Do you mind if I work on it in parallel to you? At the end either your work or mine will be thrown away (or both) but I'm fine with that since I'll learn something new. |
That sounds like a good plan, lets do it in different branches than this rfc one. |
13b6c32
to
4d803ed
Compare
I've completed the reader part! There are a few issues/notes:
|
I think implementing the writer is will be really simple. |
Co-authored-by: Martin Grigorov <[email protected]>
A start at #136
I've decided to do the RFC as a PR so it's easier to give inline commentary.
I strongly recommend reading the blog post mentioned in the references and watch the video about
rc-zip
(becomes relevant after ~10 minutes).Feel free to edit/expand the RFC.