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

[Libguestfs] [PATCH 3/4] protocol: Sleep for 1ms before reading log messages.



-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
New in Fedora 11: Fedora Windows cross-compiler. Compile Windows
programs, test, and build Windows installers. Over 70 libraries supprt'd
http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw
>From 6962c003785f48b859fedaabc77ebe0dfe85e993 Mon Sep 17 00:00:00 2001
From: Richard W.M. Jones <rjones redhat com>
Date: Fri, 1 Apr 2011 13:29:06 +0100
Subject: [PATCH 3/4] protocol: Sleep for 1ms before reading log messages.

As explained in the comment:

  /* QEMU's console emulates a 16550A serial port.  The real 16550A
   * device has a small FIFO buffer (16 bytes) which means here we see
   * lots of small reads of 1-16 bytes in length, usually single
   * bytes.  Sleeping here for a very brief period groups reads
   * together (so we usually get a few lines of output at once) and
   * improves overall throughput, as well as making the event
   * interface a bit more sane for callers.  With a virtio-serial
   * based console (not yet implemented) we may be able to remove
   * this.  XXX
   */
---
 src/proto.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/src/proto.c b/src/proto.c
index 39f30ae..7cd1d31 100644
--- a/src/proto.c
+++ b/src/proto.c
@@ -251,8 +251,15 @@ read_log_message_or_eof (guestfs_h *g, int fd, int error_if_eof)
   /* QEMU's console emulates a 16550A serial port.  The real 16550A
    * device has a small FIFO buffer (16 bytes) which means here we see
    * lots of small reads of 1-16 bytes in length, usually single
-   * bytes.
+   * bytes.  Sleeping here for a very brief period groups reads
+   * together (so we usually get a few lines of output at once) and
+   * improves overall throughput, as well as making the event
+   * interface a bit more sane for callers.  With a virtio-serial
+   * based console (not yet implemented) we may be able to remove
+   * this.  XXX
    */
+  usleep (1000);
+
   n = read (fd, buf, sizeof buf);
   if (n == 0) {
     /* Hopefully this indicates the qemu child process has died. */
-- 
1.7.4.1


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