diff options
author | Michal Privoznik <mprivozn@redhat.com> | 2020-07-03 12:30:00 +0200 |
---|---|---|
committer | Michal Privoznik <mprivozn@redhat.com> | 2020-07-03 19:09:46 +0200 |
commit | d0ac75bb9c711ee2805aaa976827ea9401592193 (patch) | |
tree | b30c47fcd3fe84f27c7d1a53ca19634cf6dbe6ab /libvirt-override-virStream.py | |
parent | 11bb65bff36e407b673da79b170debc60510224a (diff) | |
download | libvirt-python-d0ac75bb9c711ee2805aaa976827ea9401592193.tar.gz |
virStream: Use larger buffer for sendAll/recvAll methods
There are four methods which receive/send entire stream
(sendAll(), recvAll(), sparseSendAll() and sparseRecvAll()). All
these have an intermediary buffer which is either filled by
incoming stream and passed to a user provided callback to handle
the data, or the other way round - user fills it with data they
want to send and the buffer is handed over to virStream.
But the buffer is incredibly small which leads to smaller packets
being sent and thus increased overhead. What we can do is to use
the same buffer as their C counterparts do (e.g.
virStreamSendAll()) - they all use VIR_NET_MESSAGE_LEGACY_PAYLOAD_MAX
long buffer (which is the maximum size of a stream packet we
send) - this is almost exactly 256KiB (it's 256KiB - 24B for the
header).
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Diffstat (limited to 'libvirt-override-virStream.py')
-rw-r--r-- | libvirt-override-virStream.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/libvirt-override-virStream.py b/libvirt-override-virStream.py index 901c2e6..bc42704 100644 --- a/libvirt-override-virStream.py +++ b/libvirt-override-virStream.py @@ -39,7 +39,7 @@ return os.write(fd, buf) """ while True: - got = self.recv(1024*64) + got = self.recv(virStorageVol.streamBufSize) if got == -2: raise libvirtError("cannot use recvAll with " "nonblocking stream") @@ -74,7 +74,7 @@ """ while True: try: - got = handler(self, 1024*64, opaque) + got = handler(self, virStorageVol.streamBufSize, opaque) except: e = sys.exc_info()[1] try: @@ -189,7 +189,7 @@ # actually allocate the hole """ while True: - want = 64 * 1024 + want = virStorageVol.streamBufSize got = self.recvFlags(want, VIR_STREAM_RECV_STOP_AT_HOLE) if got == -2: raise libvirtError("cannot use sparseRecvAll with " @@ -251,7 +251,7 @@ self.abort() continue - want = 64 * 1024 + want = virStorageVol.streamBufSize if (want > sectionLen): want = sectionLen |