mirror of
https://gitlab.com/libvirt/libvirt-python.git
synced 2025-08-02 04:21:59 +03:00
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>
This commit is contained in:
@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user