From: Nir Soffer <nirsof@gmail.com>
To: qemu-devel@nongnu.org
Cc: "Daniel P. Berrangé" <berrange@redhat.com>,
"Richard Jones" <rjones@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Eric Blake" <eblake@redhat.com>, "Nir Soffer" <nirsof@gmail.com>
Subject: [PATCH v3 0/2] io: Increase unix stream socket buffer size
Date: Sun, 27 Apr 2025 19:50:27 +0300 [thread overview]
Message-ID: <20250427165029.9072-1-nirsof@gmail.com> (raw)
On both macOS and Linux, the default send buffer size 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 v2:
- Test with different receive buffer size (Daniel)
- Test with larger send buffer size (2m, 4m)
- Set only send buffer size - setting receive buffer size has no effect
- Increase send buffer size to 2m (based on new tests)
- Enable the change also for Linux
- Change only unix stream socket - datagram socket need different configuration
- Modify the code to make it easy to support unix datagram socket
v2 was here:
https://lists.gnu.org/archive/html/qemu-devel/2025-04/msg03167.html
Nir Soffer (2):
io: Increase unix socket buffers size on macOS
io: Increase unix socket buffers on Linux
io/channel-socket.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
--
2.39.5 (Apple Git-154)
next reply other threads:[~2025-04-27 16:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-27 16:50 Nir Soffer [this message]
2025-04-27 16:50 ` [PATCH v3 1/2] io: Increase unix socket buffers size on macOS Nir Soffer
2025-05-07 16:37 ` Daniel P. Berrangé
2025-05-07 17:17 ` Nir Soffer
2025-05-07 18:23 ` Daniel P. Berrangé
2025-04-27 16:50 ` [PATCH v3 2/2] io: Increase unix socket buffers on Linux Nir Soffer
2025-04-28 21:37 ` Eric Blake
2025-04-30 21:02 ` Nir Soffer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250427165029.9072-1-nirsof@gmail.com \
--to=nirsof@gmail.com \
--cc=berrange@redhat.com \
--cc=eblake@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=rjones@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).