[libvirt-python][PATCH 2/3] virStream: Use larger buffer for sendAll/recvAll methods

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 libvirt-override-virStream.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libvirt-override-virStream.py b/libvirt-override-virStream.py
index 901c2e6..8880218 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(262120)
             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, 262120, opaque)
             except:
                 e = sys.exc_info()[1]
                 try:
@@ -189,7 +189,7 @@
                                              # actually allocate the hole
         """
         while True:
-            want = 64 * 1024
+            want = 262120
             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 = 262120
             if (want > sectionLen):
                 want = sectionLen
 
-- 
2.26.2




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux