Skip to content
Merged
Show file tree
Hide file tree
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
14 changes: 7 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions ampc-actor-utils/src/network/mpc/handle/config.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{cmp, time::Duration};
use std::time::Duration;

#[derive(Default, Clone, Debug)]
pub struct MpcConfig {
Expand All @@ -11,24 +11,24 @@ pub struct MpcConfig {

impl MpcConfig {
pub fn new(timeout_duration: Duration, num_connections: usize, num_sessions: usize) -> Self {
// don't allow fewer requests than connections...
let connection_parallelism = cmp::min(num_connections, num_sessions);
assert!(num_connections > 0, "MPC networking requires a connection");
assert!(num_sessions > 0, "MPC networking requires a session");

Self {
timeout_duration,
num_sessions: num_sessions as u32,
num_connections: connection_parallelism as u32,
// A logical session is striped over every connection. Do not clamp
// this to the session count: batch-size-one requests need multiple
// physical flows to exceed a cloud provider's per-flow limit.
num_connections: num_connections as u32,
}
}

pub fn get_sessions_for_connection(&self, idx: u32) -> u32 {
let num_sessions = self.num_sessions;
let num_connections = self.num_connections;
num_sessions / num_connections
+ if idx < (num_sessions % num_connections) {
1
} else {
0
}
if idx < self.num_connections {
self.num_sessions
} else {
0
}
}
}
6 changes: 3 additions & 3 deletions ampc-actor-utils/src/network/mpc/handle/control_channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,19 +150,19 @@ impl<T: NetworkConnection> ControlChannel for TcpControlChannel<T> {
}

async fn sync(&mut self) -> Result<()> {
let token = NetworkValue::Bytes(SYNC_TOKEN_BYTES.to_vec());
let token = NetworkValue::Bytes(SYNC_TOKEN_BYTES.to_vec().into());
self.send_next(token.clone()).await?;
self.send_prev(token).await?;

let next_token = self.recv_next().await?;
match next_token {
NetworkValue::Bytes(ref bytes) if bytes == SYNC_TOKEN_BYTES => {}
NetworkValue::Bytes(ref bytes) if &bytes[..] == SYNC_TOKEN_BYTES => {}
_ => bail!("invalid sync token received from next party"),
}

let prev_token = self.recv_prev().await?;
match prev_token {
NetworkValue::Bytes(ref bytes) if bytes == SYNC_TOKEN_BYTES => {}
NetworkValue::Bytes(ref bytes) if &bytes[..] == SYNC_TOKEN_BYTES => {}
_ => bail!("invalid sync token received from prev party"),
}

Expand Down
Loading
Loading