These are wrappers over virStreamRecv and virStreamSend so that
users have to care about nothing but writing data into / reading
data from a sink (typically a file). Note, that these wrappers
are used exclusively on client side as the daemon has slightly
different approach. Anyway, the wrappers allocate this buffer and
use it for intermediate data storage until the data is passed to
stream to send, or to the client application. So far, we are
using 64KB buffer. This is enough, but suboptimal because server
can send messages up to VIR_NET_MESSAGE_LEGACY_PAYLOAD_MAX bytes
big (262120B, roughly 256KB). So if we make the buffer this big,
a single message containing the data is sent instead of four,
which is current situation. This means lower overhead, because
each message contains a header which needs to be processed, each
message is processed roughly same amount of time regardless of
its size, less bytes need to be sent through the wire, and so on.
Note that since server will never sent us a stream message bigger
than VIR_NET_MESSAGE_LEGACY_PAYLOAD_MAX there's no point in
sizing up the client buffer past this threshold.

Signed-off-by: Michal Privoznik <mpriv...@redhat.com>
---
 src/libvirt-stream.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/libvirt-stream.c b/src/libvirt-stream.c
index c16f586..8384b37 100644
--- a/src/libvirt-stream.c
+++ b/src/libvirt-stream.c
@@ -23,6 +23,7 @@
 #include "datatypes.h"
 #include "viralloc.h"
 #include "virlog.h"
+#include "rpc/virnetprotocol.h"
 
 VIR_LOG_INIT("libvirt.stream");
 
@@ -330,7 +331,7 @@ virStreamSendAll(virStreamPtr stream,
                  void *opaque)
 {
     char *bytes = NULL;
-    int want = 1024*64;
+    size_t want = VIR_NET_MESSAGE_LEGACY_PAYLOAD_MAX;
     int ret = -1;
     VIR_DEBUG("stream=%p, handler=%p, opaque=%p", stream, handler, opaque);
 
@@ -423,7 +424,7 @@ virStreamRecvAll(virStreamPtr stream,
                  void *opaque)
 {
     char *bytes = NULL;
-    int want = 1024*64;
+    size_t want = VIR_NET_MESSAGE_LEGACY_PAYLOAD_MAX;
     int ret = -1;
     VIR_DEBUG("stream=%p, handler=%p, opaque=%p", stream, handler, opaque);
 
-- 
2.8.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to