Skip to content

Commit

Permalink
feat(rust): increased portal throughput by increasing payload size
Browse files Browse the repository at this point in the history
  • Loading branch information
davide-baldo committed Nov 28, 2024
1 parent b3846c8 commit d8098bd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
8 changes: 4 additions & 4 deletions implementations/rust/ockam/ockam_api/tests/portals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,12 @@ fn portal_node_goes_down_reconnect() {
#[test]
fn portal_low_bandwidth_connection_keep_working_for_60s() {
// in this test we use two nodes, connected through a passthrough server
// which limits the bandwidth to 64kb per second
// which limits the bandwidth to 170kb per second
//
// ┌────────┐ ┌───────────┐ ┌────────┐
// │ Node └─────► TCP └────────► Node │
// │ 1 ◄─────┐Passthrough◄────────┐ 2 │
// └────┬───┘ │ 64KB/s │ └────▲───┘
// └────┬───┘ │ 170KB/s │ └────▲───┘
// │ └───────────┘ │
// │ ┌───────────┐ │
// │ Portal │ TCP │ Outlet │
Expand Down Expand Up @@ -270,8 +270,8 @@ fn portal_low_bandwidth_connection_keep_working_for_60s() {

let passthrough_server_handle = start_passthrough_server(
&second_node_listen_address.to_string(),
Disruption::LimitBandwidth(64 * 1024),
Disruption::LimitBandwidth(64 * 1024),
Disruption::LimitBandwidth(170 * 1024),
Disruption::LimitBandwidth(170 * 1024),
)
.await;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ pub enum PortalInternalMessage {
}

/// Maximum allowed size for a payload
pub const MAX_PAYLOAD_SIZE: usize = 48 * 1024;
pub const MAX_PAYLOAD_SIZE: usize = 128 * 1024;

#[cfg(test)]
mod test {
Expand Down
4 changes: 3 additions & 1 deletion tools/stress-test/src/portal_simulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ use ockam_multiaddr::MultiAddr;

use crate::config::Throughput;

pub const MAX_PAYLOAD_SIZE: usize = 128 * 1024;

pub struct PortalStats {
pub messages_out_of_order: Arc<AtomicU64>,
pub bytes_received: Arc<AtomicU64>,
Expand Down Expand Up @@ -97,7 +99,7 @@ impl Processor for PortalSimulatorSender {

while bytes_left > 0 {
let next_message_number = self.messages_sent.fetch_add(1, Ordering::Relaxed);
let payload_size = std::cmp::min(bytes_left, 48 * 1024);
let payload_size = std::cmp::min(bytes_left, MAX_PAYLOAD_SIZE);
let mut message = Vec::with_capacity(8 + 8 + payload_size);

message.extend_from_slice(&next_message_number.to_le_bytes());
Expand Down

0 comments on commit d8098bd

Please sign in to comment.