From 72ddb6de1028426305df3ab6c81ff3834d5a69e5 Mon Sep 17 00:00:00 2001 From: Gleb Smirnoff Date: Fri, 22 Aug 2025 09:22:25 -0700 Subject: [PATCH] unix: increase net.local.(stream|seqpacket).(recv|send)space to 64 KiB The limit of 8 KiB comes straight from the 80-ies, when memory sizes were two orders of magnitude less. Microbenchmarking clearly shows that increased maximum buffer size is needed to improve bulk transfer performance over unix(4). Most operating system have larger default sizes. This brings us another reason for increase. A buggy application, that treats a stream socket as a datagram socket, shall work on Linux as long as its messages are smaller than socket buffer size without any issues 99.99% of time. But on FreeBSD it will instantly fail. In the ports system there are already applications that suggest increase of this sysctls for the application to work. We don't want to be a bug catcher for bad applications in the default configuration. Note that buffer size increase will not increase memory usage even on a system with a million unix(4) sockets at normal runtime, as long as applications are written properly and receivers drain their sockets and system has enough CPU time for them to do that. Reviewed by: peter.lei_ieee.org, rscheff, tuexen Differential Revision: https://reviews.freebsd.org/D51903 --- sys/kern/uipc_usrreq.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index 0056dac65c7..19870e98943 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -154,15 +154,12 @@ static struct task unp_defer_task; * and don't really want to reserve the sendspace. Their recvspace should be * large enough for at least one max-size datagram plus address. */ -#ifndef PIPSIZ -#define PIPSIZ 8192 -#endif -static u_long unpst_sendspace = PIPSIZ; -static u_long unpst_recvspace = PIPSIZ; +static u_long unpst_sendspace = 64*1024; +static u_long unpst_recvspace = 64*1024; static u_long unpdg_maxdgram = 8*1024; /* support 8KB syslog msgs */ static u_long unpdg_recvspace = 16*1024; -static u_long unpsp_sendspace = PIPSIZ; -static u_long unpsp_recvspace = PIPSIZ; +static u_long unpsp_sendspace = 64*1024; +static u_long unpsp_recvspace = 64*1024; static SYSCTL_NODE(_net, PF_LOCAL, local, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, "Local domain");