From 12af6f73218ed3e047527aa83f95387da962d071 Mon Sep 17 00:00:00 2001 From: Steven Moreland Date: Tue, 7 Mar 2023 15:14:25 +0000 Subject: RPC Binder: disable Nagle's algorithm For some reason, I thought we did this - I thought it was incidental to some other API we used. RPC Binder is an RPC system, AND ONE WITH SYNCHRONOUS CALLS! It should not hold these packets. Bug: 271860373 Test: run inet cases before/after: binderRpcTest --gtest_filter="*PerSocket/BinderRpc.RepeatBinderNull/inet_socket_tls_clientV0_serverV4026531840_single_threaded_no_kernel*" before: 0m26.845s after: 0m12.271s Change-Id: Ib257b53cd2e4ca19041cdb5fd985be346e3fac5e --- libs/binder/RpcSession.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'libs/binder/RpcSession.cpp') diff --git a/libs/binder/RpcSession.cpp b/libs/binder/RpcSession.cpp index 1a821f14c9..bba0bcb04a 100644 --- a/libs/binder/RpcSession.cpp +++ b/libs/binder/RpcSession.cpp @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -608,6 +609,18 @@ status_t RpcSession::setupOneSocketConnection(const RpcSocketAddress& addr, return -savedErrno; } + if (addr.addr()->sa_family == AF_INET || addr.addr()->sa_family == AF_INET6) { + int noDelay = 1; + int result = + setsockopt(serverFd.get(), IPPROTO_TCP, TCP_NODELAY, &noDelay, sizeof(noDelay)); + if (result < 0) { + int savedErrno = errno; + ALOGE("Could not set TCP_NODELAY on %s: %s", addr.toString().c_str(), + strerror(savedErrno)); + return -savedErrno; + } + } + RpcTransportFd transportFd(std::move(serverFd)); if (0 != TEMP_FAILURE_RETRY(connect(transportFd.fd.get(), addr.addr(), addr.addrSize()))) { -- cgit v1.2.3-59-g8ed1b