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
This commit is contained in:
Gleb Smirnoff
2025-08-22 09:22:25 -07:00
parent 6d95b2023e
commit 72ddb6de10
+4 -7
View File
@@ -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");