Skip to content
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

[client] Take more advantage of pipelined NUSB sending #70

Open
jamesmunns opened this issue Dec 20, 2024 · 1 comment
Open

[client] Take more advantage of pipelined NUSB sending #70

jamesmunns opened this issue Dec 20, 2024 · 1 comment

Comments

@jamesmunns
Copy link
Owner

Right now, the transmitting of data with NUSB generally awaits the transfer to be complete. We could instead just submit, and then return, allowing multiple submissions to be sent nose-to-tail.

I tried this diff, and it didn't seem to help as much as I would have hoped, but we might need #69 to realize the improvements. One downside of this is that if there is an error, it will show up at the "wrong time", though it's likely that the input worker will notice a disconnect first anyway.

 impl NusbWireTx {
     async fn send_inner(&mut self, data: Vec<u8>) -> Result<(), NusbWireTxError> {
-        self.boq.submit(data);
-
-        let send_res = self.boq.next_complete().await;
-        if let Err(e) = send_res.status {
-            tracing::error!("Output Queue Error: {e:?}");
-            return Err(e.into());
+        while self.boq.pending() != 0 {
+            let send_res = self.boq.next_complete().await;
+            if let Err(e) = send_res.status {
+                tracing::error!("Output Queue Error: {e:?}");
+                return Err(e.into());
+            }
         }
+        self.boq.submit(data);
         Ok(())
     }
 }
@jamesmunns
Copy link
Owner Author

Ah, this isn't good either, we still wait for pending frames to complete. That explains the lack of perf difference. We might want to select on completion and maybe another intermediate channel? The worker tasks being outside of the interfaces may have been the wrong place to draw the interface line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant