qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/3] nbd: Increase unix socket buffer size
@ 2025-05-17 20:11 Nir Soffer
  2025-05-17 20:11 ` [PATCH v4 1/3] io: Add helper for setting socket send " Nir Soffer
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Nir Soffer @ 2025-05-17 20:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: Daniel P. Berrangé, Eric Blake, Philippe Mathieu-Daudé,
	Richard Jones, Vladimir Sementsov-Ogievskiy, qemu-block,
	Nir Soffer

On both macOS and Linux, the default send buffer size is too small causing poor
performance when reading and writing to qemu-nbd. A simple way to experience
this is to compare TCP and unix sockets, showing that TCP socket is much
faster. Programs like nbdcopy partly mitigate this by using multiple NBD
connections.

On macOS the default send buffer size is 8192 bytes. Increasing the send buffer
size to 2 MiB shows up to *12.6 times higher throughput* and lower cpu usage.

On Linux the default and maximum buffer size is 212992 bytes. Increasing the
send buffer size to 2 MiB shows up to *2.7 times higher throughput* and lower
cpu usage. On older machine we see very little improvement, up to 1.03 times
higher throughput.

We likely have the same issue on other platforms. It should be easy to enable
this change for more platform by defining UNIX_STREAM_SOCKET_SEND_BUFFER_SIZE.

Changes since v3:
- Modify only NBD sockets, since not all sockets need a larger buffer size, and
  the fixed memory overhead per socker may be a significant amount of extra
  memory overhead on a host. (Daniel)
- Add qio_channel_socket_set_send_buffer() helper to set buffer size from nbd
  code.
- Remove the check for SOCK_STREAM since NBD does not support SOCK_DGRAM.
- Warn if we fail to set the socket send buffer size.

v3 was here:
https://lists.gnu.org/archive/html/qemu-devel/2025-04/msg05096.html

Nir Soffer (3):
  io: Add helper for setting socket send buffer size
  nbd: Set unix socket send buffer on macOS
  nbd: Set unix socket send buffer on Linux

 include/io/channel-socket.h | 13 +++++++++++++
 io/channel-socket.c         | 11 +++++++++++
 nbd/client-connection.c     |  3 +++
 nbd/common.c                | 26 ++++++++++++++++++++++++++
 nbd/nbd-internal.h          |  5 +++++
 nbd/server.c                |  2 ++
 6 files changed, 60 insertions(+)

-- 
2.39.5 (Apple Git-154)



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2025-05-19 20:13 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-17 20:11 [PATCH v4 0/3] nbd: Increase unix socket buffer size Nir Soffer
2025-05-17 20:11 ` [PATCH v4 1/3] io: Add helper for setting socket send " Nir Soffer
2025-05-19 10:46   ` Daniel P. Berrangé
2025-05-19 11:20   ` Richard W.M. Jones
2025-05-19 20:11     ` Eric Blake
2025-05-17 20:11 ` [PATCH v4 2/3] nbd: Set unix socket send buffer on macOS Nir Soffer
2025-05-19 10:47   ` Daniel P. Berrangé
2025-05-17 20:11 ` [PATCH v4 3/3] nbd: Set unix socket send buffer on Linux Nir Soffer
2025-05-19 10:47   ` Daniel P. Berrangé
2025-05-19 20:12 ` [PATCH v4 0/3] nbd: Increase unix socket buffer size Eric Blake

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).