-
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
feat: add simple RDMA communication support #2
base: master
Are you sure you want to change the base?
Conversation
Server handles both HTTP and RDMA requests through `serve_with_rdma`. Client has two options to communicate with the server: either HTTP via Channel or RDMA via RdmaChannel. RDMA communication based on `async-rdma` crate.
Client establishess an RDMA connection to the server through `connect_rdma`.
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.
If possible, can we merge the rdma code into the original logic, especially for the code generation part? There are too many duplicate code. And we can add an rdma
feature flag to support the rdma statically.
@@ -146,6 +168,27 @@ fn generate_connect(service_ident: &syn::Ident, enabled: bool) -> TokenStream { | |||
} | |||
} | |||
|
|||
#[cfg(feature = "transport")] | |||
fn generate_connect_rdma(service_ident: &syn::Ident, enable: bool) -> TokenStream { |
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.
http version ignores the enable
parameter, why do we care about it?
); | ||
|
||
// if !disable_comments.contains(&format!( | ||
// "{}{}{}.{}", |
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.
remove the commented code.
@@ -197,6 +240,139 @@ fn generate_methods<T: Service>( | |||
stream | |||
} | |||
|
|||
fn generate_methods_rdma<T: Service>( |
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.
try not to duplicate the code if many are the same or similar.
// body | ||
source | ||
.for_each(|item| { | ||
len += encoder.encode_into_slice(item, &mut buf).unwrap(); |
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.
How to make sure the len is within mr's len?
If you ensure that by MAX_MSG_LEN
, you can add a comment to explain why is it that number.
pub trait RdmaService { | ||
/// | ||
fn alloc_mr(&self) -> io::Result<LocalMr>; | ||
/// |
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.
Forget to add comments?
|
||
// TODO: handle this error | ||
async fn rdma_serve_inner(rdma: Arc<Rdma>, mut routes: RdmaRoutes) -> Result<(), io::Error> { | ||
println!("[server] connected!"); |
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.
debug!
might be better?
@@ -0,0 +1,202 @@ | |||
use std::collections::HashMap; |
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.
Maybe we can add this example to github action as a test and show the usage.
Motivation
Currently tonic only supports HTTP, so I tried to add optional RDMA communication feature.
Using RDMA(if machine supports) can improve communication efficiency.
Solution
RDMA communication based on
async-rdma
crate. RDMA establishes a connection via TCP, then communicates using SEND/RECV operations.Server handles both HTTP and RDMA requests through
serve_with_rdma
. This function listens to two TCP ports, which are used for HTTP and RDMA connection establishment respectively.Client has two options to communicate with the server: either HTTP via Channel(
connect
) or RDMA via RdmaChannel(connect_rdma
).