-
Notifications
You must be signed in to change notification settings - Fork 2
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
AsyncRead and AsyncWrite support #5
Comments
That's a good question. Essrpc was originally written before async/await was fully standardized. Let me see what I can do to both document things and clean them up to match current best practices. |
I've started working on this on a new |
Great. Thanks for such a quick response. I'll check this branch out. |
I'm sure you already know this limitation — it's clear from your comment in
when I try the async code. |
Yes, that's one of the things I want to fix before merging the branch back. But I don't actually have an example that fails currently. I'm not sure how easily yours extracts from the rest of your codebase, but if it does I'd love to include it in a test. |
I just added example in mrzv/essrpc@66228f2. Not sure how to turn it into a test, but if you run it with
it will give the error. |
Sorry for the slow progress here -- I'm not sure where the time goes. I have added a test based on your example, and pushed changes to the async branch with a frame format around bincode so that the test passes (the transport now knows how many bytes to read), but I'm not entirely happy with it. I don't think I've entirely grokked the async world: how best to share code between sync and async implementations and how best to deal with underlying libraries (such as bincode) that expect to work with sync readers. Changing the actual wire format to support async feels gross... |
Thanks. I'll check it out. I see some As for the rest, I'm afraid I'm a complete newbie to Rust, so I don't have anything meaningful to offer. I'm still fumbling around async, so no real insight there. Either way, many thanks for all your work on this. |
Super. This works in my code. Thanks again! I have some thoughts on how async code could be re-organized to make the user experience better (mostly to not have to deal with switching between tokio and async-std futures), but that's probably best discussed in another issue. It's a cosmetic matter anyway. |
Two questions. When I run I'm trying to use the new code in my project, and I switched from |
Never mind the first question. I was missing Any debugging advice is appreciated. |
Ok, never mind all that. I've added a |
Sorry for the continuingly slow replies. Interestingly I didn't get the hang at the same point you do, but I do get it if I increase the big buffer size all the way up to 256kb. Debugging now... BTW I usually use an old-fashioned Makefile on top of Cargo to abstract away giving the necessary feature arguments (and have one in this repo). Running |
I'm guessing it's something platform-dependent. The other concerning bit is that if you make the buffer very large (128MiB), the And thanks for the pointer to |
There were bugs in the parsing of the ServerTransport bincode implementation -- I hadn't properly updated it for the new framed format. I've pushed changes to the async branch. Also a client bug where I called BTW you asked about debugging. I'm not sure what your background is, but for me the debugging process for rust is the same as it would be for C++. For a hang I run the program under gdb. Once i repro the hang under the debugger, I break execution and run |
Thanks! Currently, for me, The speed mystery is also solved. It was caused by the missing Thanks for the pointers on debugging. They are helpful. My questions were more about what are the relevant bits of code to look at. I was trying to debug a remote server (running over SSH on a different machine), so attaching a debugger would be trickier. But it's all good. Thanks again. |
Yes, I need to make similar fixes for the json transport to what I've made in bincode. Interesting, we're seeing very different speed characteristics.On my system (Arch Linux, i7-7700K cpu, Rust 1.54), |
I'm getting this on a 5-year-old MacBook Pro. But I wouldn't worry about these numbers. I tried the code in a real application today, where the client is on the MacBook Pro, the server is on a beefy ArchLinux workstation, and they are talking using this RPC library over SSH. I got a sustained 60MiB/s data transfer, which is as high as I can get over SSH. So it looks very good. |
Do you mind releasing what's in the |
I don't mean to be pushy, but do you mind releasing what's currently in |
Sorry for the delay here. As you noted earlier in this thread, the json transport is broken and needs cleaning up. Trying to get that working now, as well as some additional cleanup |
Ok, sorry again this took so long but I've just published 0.4. It does make some tweaks vs what was in the async branch earlier -- I took a dependency on Tokio to tokio_util::codec::Framed in the bincode transport instead of doing my own framing. Since I was now depending on Tokio anyway, I now use the AsyncRead and AsyncWrite traits from Tokio as well. |
Great. Thanks! I'll try it out and tweak my code as necessary. |
Hm, when I add
Any idea what could be causing this? Can there be some internal conflict of the dependencies, or something? |
I get the same error, when I try to build what's in your repo now. |
Correction, not the same, but similar:
|
Sorry, I forgot to push some commits to the repo (pushed now), which definitely explains the second issue. I'm a bit confused by the first issue though when you're referencing crates.io. I wonder if there could be a caching/propagation delay in crates.io? I just tried it now -- created a new project with
And |
Hm, your repository contents compile for me now, but the original problem is still there. If I do
but when I run
Changing |
Hm, I just tried it on a different machine (Linux vs Mac), and |
Removing |
Well, my main code is broken with the new version (after the minor adjustments to make it compile). It looks like I get the error on the server side ( |
|
I'm a bit surprised -- the main change in the bincode transport was to switch to Tokio's Regarding |
It looks like that was my mistake. I must have had a mismatch between client and server code, where the server was compiled using the older version of essrpc. So it's probably that the framing didn't match. At least, when I'm trying it now, it seems to work. If I uncover more, I'll let you know. The buffer size is an issue for me. I'm transferring entire files as function arguments, and there is not really a limit on their size. It sounds like I'll have to figure out chunking myself somehow. On the other hand, it would make it more user-friendly, if essrpc could chunk the arguments itself. |
Just to add, it's not just files that will exceed 8MiB. I also have vectors (of structures) that I want to pass around that are larger than that. |
Just for my own edification: why does tokio's framing need max size, while yours didn't? |
If I'm reading length_delimited correctly, the |
My read of the Tokio code is the same. I've just published 0.4.1 which removes the frame length restriction entirely (sets it to |
That's perfect. |
I'm trying to figure out how to use the
async
side of the code. Specifically, I'd like to replace an example that spawns anstd::process::Child
, via aCommand
, and interacts with its stdio viaRead
/Write
traits, with an example that usestokio::process::{Command,Child}
. Its stdio is implemented via traitsAsyncRead
/AsyncWrite
. Right now, as far as I can tell, I'm supposed to wrap them in anasync
function, which gets passed toBincodeAsyncClientTransport
. (An example like this would be amazing, by the way.) I'm wondering if it makes sense and would be possible to add support forAsyncRead
/AsyncWrite
directly to essrpc, to mirror theRead
/Write
interface?The text was updated successfully, but these errors were encountered: