From 65230040083eeca3d8a91905567e7341bd671103 Mon Sep 17 00:00:00 2001 From: Dom Dwyer Date: Wed, 23 Aug 2023 18:07:39 +0200 Subject: [PATCH] perf: enable TCP_NODELAY on gRPC servers This change forces TCP_NODELAY to be set, which is the default for tonic, and is enabled by default, but is silently discarded when using serve_with_incoming_shutdown(). --- ioxd_common/src/rpc.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ioxd_common/src/rpc.rs b/ioxd_common/src/rpc.rs index 2ea5af2af3..8f25f326c4 100644 --- a/ioxd_common/src/rpc.rs +++ b/ioxd_common/src/rpc.rs @@ -130,7 +130,6 @@ macro_rules! setup_builder { #[macro_export] macro_rules! serve_builder { ($builder:ident) => {{ - use $crate::reexport::tokio_stream::wrappers::TcpListenerStream; use $crate::rpc::RpcBuilder; let RpcBuilder { @@ -140,7 +139,10 @@ macro_rules! serve_builder { .. } = $builder; - let stream = TcpListenerStream::new(socket); + let stream = $crate::reexport::tonic::transport::server::TcpIncoming::from_listener( + socket, true, None, + ) + .expect("failed to initialise tcp socket"); inner .serve_with_incoming_shutdown(stream, shutdown.cancelled()) .await?;