Skip to content

perf fix for channel over MetaTls #636

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions hyperactor/src/channel/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3174,4 +3174,51 @@ mod tests {
handle.await.unwrap();
}
}

#[async_timed_test(timeout_secs = 60)]
async fn test_meta_tls_throughput() {
let subscriber = tracing_subscriber::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::new("debug"))
.finish();
tracing::subscriber::set_global_default(subscriber).expect("Failed to set subscriber");

async fn send_message(addr: ChannelAddr) -> Duration {
let (local_addr, mut rx) = crate::channel::serve::<String>(addr).await.unwrap();
tracing::info!("local_addr: {:?}", local_addr);
{
let size = 200 * 1000 * 1000;
let msg = "x".repeat(size);
let tx = dial::<String>(local_addr).unwrap();
let now: Instant = Instant::now();
tx.try_post(msg.clone(), unused_return_channel()).unwrap();
assert_eq!(rx.recv().await.unwrap(), msg);

let elapsed = now.elapsed();
tracing::info!("elapsed: {:?}", elapsed);
elapsed
}
}

{
tracing::info!("testing with metatls");
let addr = ChannelAddr::any(ChannelTransport::MetaTls);
let elapsed = send_message(addr).await;
// e.g. elapsed: 650ms
assert!(elapsed.as_secs() < 2);
}

{
tracing::info!("testing with tcp");
let addr = ChannelAddr::any(ChannelTransport::Tcp);
match addr {
ChannelAddr::Tcp(addr) => {
assert!(!addr.ip().is_loopback());
}
_ => panic!("unexpected addr: {:?}", addr),
}
let elapsed = send_message(addr).await;
// e.g elapsed: 350ms
assert!(elapsed.as_secs() < 2);
}
}
}
Loading