Both buffer size and file recommended

Please Linux kernel hackers, what is a reasonable write(2)syscall buffer size for sockets or files, in terms of performance? It’s clear that these are several multiple pages, but which one? Does it matter? What is “too small” and “too large”?

+5
source share
1 answer

depends on how long your peer delay is, say you have a 100 Mbps connection and a delay of 50 ms, then you can calculate

100MBps * 0.050 sec / 8 = 0.625MB = 625KB

Linux 2.6 110 , 2,2 / (110 /0,050) , , setsockopt

int ret, sock, buf_size;
sock = socket(AF_INET, SOCK_STREAM, 0);
buf_size = 625*1024;
ret = setsockopt(sock, SOL_SOCKET, SO_SNDBUF, (char *)&buf_size, sizeof(buf_size));
ret = setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (char *)&buf_size, sizeof(buf_size));
+7

All Articles