From 8efe9ef93822016aa4f6ce4d3eb4b390e1816ade Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Tue, 3 Dec 2024 14:27:59 +0100 Subject: [PATCH] perf: make network buffers a power of two --- src/executor/device.rs | 2 +- src/executor/network.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/executor/device.rs b/src/executor/device.rs index e3d1facefa..2a00b8d122 100644 --- a/src/executor/device.rs +++ b/src/executor/device.rs @@ -195,7 +195,7 @@ impl Device for HermitNet { fn capabilities(&self) -> DeviceCapabilities { let mut cap = DeviceCapabilities::default(); cap.max_transmission_unit = self.mtu.into(); - cap.max_burst_size = Some(0xffff / cap.max_transmission_unit); + cap.max_burst_size = Some(0x10000 / cap.max_transmission_unit); cap.checksum = self.checksums.clone(); cap } diff --git a/src/executor/network.rs b/src/executor/network.rs index 5bc91433ec..f82e867f15 100644 --- a/src/executor/network.rs +++ b/src/executor/network.rs @@ -243,9 +243,9 @@ impl<'a> NetworkInterface<'a> { #[cfg(feature = "udp")] pub(crate) fn create_udp_handle(&mut self) -> Result { let udp_rx_buffer = - udp::PacketBuffer::new(vec![udp::PacketMetadata::EMPTY; 4], vec![0; 0xffff]); + udp::PacketBuffer::new(vec![udp::PacketMetadata::EMPTY; 4], vec![0; 0x10000]); let udp_tx_buffer = - udp::PacketBuffer::new(vec![udp::PacketMetadata::EMPTY; 4], vec![0; 0xffff]); + udp::PacketBuffer::new(vec![udp::PacketMetadata::EMPTY; 4], vec![0; 0x10000]); let udp_socket = udp::Socket::new(udp_rx_buffer, udp_tx_buffer); let udp_handle = self.sockets.add(udp_socket); @@ -254,8 +254,8 @@ impl<'a> NetworkInterface<'a> { #[cfg(feature = "tcp")] pub(crate) fn create_tcp_handle(&mut self) -> Result { - let tcp_rx_buffer = tcp::SocketBuffer::new(vec![0; 0xffff]); - let tcp_tx_buffer = tcp::SocketBuffer::new(vec![0; 0xffff]); + let tcp_rx_buffer = tcp::SocketBuffer::new(vec![0; 0x10000]); + let tcp_tx_buffer = tcp::SocketBuffer::new(vec![0; 0x10000]); let mut tcp_socket = tcp::Socket::new(tcp_rx_buffer, tcp_tx_buffer); tcp_socket.set_nagle_enabled(true); let tcp_handle = self.sockets.add(tcp_socket);