]> git.ipfire.org Git - thirdparty/libvirt.git/commit
remote: make ssh-helper massively faster
authorDaniel P. Berrangé <berrange@redhat.com>
Wed, 25 Nov 2020 17:22:51 +0000 (17:22 +0000)
committerDaniel P. Berrangé <berrange@redhat.com>
Thu, 26 Nov 2020 10:14:18 +0000 (10:14 +0000)
commit829142699ecf1b51e677c6719fce29282af62c92
treead06fb8709fb136e600df5358f2ea1bd2e0f4563
parent259b43673fd360c7efe40631a70105e71ff10fc8
remote: make ssh-helper massively faster

It was reported that the performance of tunnelled migration and
volume upload/download regressed in 6.9.0, when the virt-ssh-helper
is used for remote SSH tunnelling instead of netcat.

When seeing data available to read from stdin, or the socket,
the current code will allocate at most 1k of extra space in
the buffer it has.

After writing data to the socket, or stdout, if more than 1k
of extra space is in the buffer, it will reallocate to free
up that space.

This results in a huge number of mallocs when doing I/O, as
well as a huge number of syscalls since at most 1k of data
will be read/written at a time.

Also if writing blocks for some reason, it will continue to
read data with no memory bound which is bad.

This changes the code to use a 1 MB fixed size buffer in each
direction. If that buffer becomes full, it will update the
watches to stop reading more data. It will never reallocate
the buffer at runtime.

This increases the performance by orders of magnitude.

Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
src/remote/remote_ssh_helper.c