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().
pull/24376/head
Dom Dwyer 2023-08-23 18:07:39 +02:00
parent 6e1d371460
commit 6523004008
No known key found for this signature in database
GPG Key ID: E4C40DBD9157879A
1 changed files with 4 additions and 2 deletions

View File

@ -130,7 +130,6 @@ macro_rules! setup_builder {
#[macro_export] #[macro_export]
macro_rules! serve_builder { macro_rules! serve_builder {
($builder:ident) => {{ ($builder:ident) => {{
use $crate::reexport::tokio_stream::wrappers::TcpListenerStream;
use $crate::rpc::RpcBuilder; use $crate::rpc::RpcBuilder;
let RpcBuilder { let RpcBuilder {
@ -140,7 +139,10 @@ macro_rules! serve_builder {
.. ..
} = $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 inner
.serve_with_incoming_shutdown(stream, shutdown.cancelled()) .serve_with_incoming_shutdown(stream, shutdown.cancelled())
.await?; .await?;