diff --git a/dragonfly-client-storage/src/client/mod.rs b/dragonfly-client-storage/src/client/mod.rs index c00694e7..c2d8bc5a 100644 --- a/dragonfly-client-storage/src/client/mod.rs +++ b/dragonfly-client-storage/src/client/mod.rs @@ -20,10 +20,10 @@ pub mod tcp; use std::time::Duration; /// DEFAULT_SEND_BUFFER_SIZE is the default size of the send buffer for network connections. -const DEFAULT_SEND_BUFFER_SIZE: usize = 4 * 1024 * 1024; +const DEFAULT_SEND_BUFFER_SIZE: usize = 16 * 1024 * 1024; /// DEFAULT_RECV_BUFFER_SIZE is the default size of the receive buffer for network connections. -const DEFAULT_RECV_BUFFER_SIZE: usize = 4 * 1024 * 1024; +const DEFAULT_RECV_BUFFER_SIZE: usize = 16 * 1024 * 1024; /// DEFAULT_KEEPALIVE_INTERVAL is the default interval for sending keepalive messages. const DEFAULT_KEEPALIVE_INTERVAL: Duration = Duration::from_secs(5); diff --git a/dragonfly-client-storage/src/client/tcp.rs b/dragonfly-client-storage/src/client/tcp.rs index 2a4b8da0..ba77eea9 100644 --- a/dragonfly-client-storage/src/client/tcp.rs +++ b/dragonfly-client-storage/src/client/tcp.rs @@ -179,6 +179,15 @@ impl TCPClient { socket.set_tcp_keepalive( &TcpKeepalive::new().with_interval(super::DEFAULT_KEEPALIVE_INTERVAL), )?; + #[cfg(target_os = "linux")] + { + use tracing::warn; + if let Err(err) = socket.set_tcp_fastopen(true) { + warn!("failed to set tcp fast open: {}", err); + } else { + info!("set tcp fast open"); + } + } let (reader, mut writer) = stream.into_split(); writer.write_all(&request).await.inspect_err(|err| { diff --git a/dragonfly-client-storage/src/server/mod.rs b/dragonfly-client-storage/src/server/mod.rs index c00694e7..c2d8bc5a 100644 --- a/dragonfly-client-storage/src/server/mod.rs +++ b/dragonfly-client-storage/src/server/mod.rs @@ -20,10 +20,10 @@ pub mod tcp; use std::time::Duration; /// DEFAULT_SEND_BUFFER_SIZE is the default size of the send buffer for network connections. -const DEFAULT_SEND_BUFFER_SIZE: usize = 4 * 1024 * 1024; +const DEFAULT_SEND_BUFFER_SIZE: usize = 16 * 1024 * 1024; /// DEFAULT_RECV_BUFFER_SIZE is the default size of the receive buffer for network connections. -const DEFAULT_RECV_BUFFER_SIZE: usize = 4 * 1024 * 1024; +const DEFAULT_RECV_BUFFER_SIZE: usize = 16 * 1024 * 1024; /// DEFAULT_KEEPALIVE_INTERVAL is the default interval for sending keepalive messages. const DEFAULT_KEEPALIVE_INTERVAL: Duration = Duration::from_secs(5); diff --git a/dragonfly-client-storage/src/server/tcp.rs b/dragonfly-client-storage/src/server/tcp.rs index 586d1b95..84600cd1 100644 --- a/dragonfly-client-storage/src/server/tcp.rs +++ b/dragonfly-client-storage/src/server/tcp.rs @@ -100,10 +100,17 @@ impl TCPServer { #[cfg(target_os = "linux")] { use tracing::warn; - if let Err(err) = socket.set_tcp_congestion("bbr".as_bytes()) { + if let Err(err) = socket.set_tcp_congestion("cubic".as_bytes()) { warn!("failed to set tcp congestion: {}", err); + } else { + info!("set tcp congestion to cubic"); + } + + if let Err(err) = socket.set_tcp_fastopen(true) { + warn!("failed to set tcp fast open: {}", err); + } else { + info!("set tcp fast open"); } - info!("set tcp congestion to bbr"); } socket.bind(&self.addr.into())?;