Skip to content

Commit

Permalink
perf: make network buffers a power of two
Browse files Browse the repository at this point in the history
  • Loading branch information
mkroening committed Dec 3, 2024
1 parent b0889d7 commit 8efe9ef
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/executor/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 4 additions & 4 deletions src/executor/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,9 @@ impl<'a> NetworkInterface<'a> {
#[cfg(feature = "udp")]
pub(crate) fn create_udp_handle(&mut self) -> Result<Handle, ()> {
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);

Expand All @@ -254,8 +254,8 @@ impl<'a> NetworkInterface<'a> {

#[cfg(feature = "tcp")]
pub(crate) fn create_tcp_handle(&mut self) -> Result<Handle, ()> {
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);
Expand Down

0 comments on commit 8efe9ef

Please sign in to comment.