qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Lieven <pl@kamp.de>
To: Gerd Hoffmann <kraxel@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [RfC PATCH 07/10] io: add qio_buffer tracing
Date: Fri, 25 Sep 2015 10:10:57 +0200	[thread overview]
Message-ID: <56050191.2020107@kamp.de> (raw)
In-Reply-To: <1443084128-25552-8-git-send-email-kraxel@redhat.com>

Am 24.09.2015 um 10:42 schrieb Gerd Hoffmann:
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  io/buffer.c  | 10 ++++++++++
>  trace-events |  6 ++++++
>  2 files changed, 16 insertions(+)
>
> diff --git a/io/buffer.c b/io/buffer.c
> index 96077d3..05425c2 100644
> --- a/io/buffer.c
> +++ b/io/buffer.c
> @@ -19,6 +19,7 @@
>   */
>  
>  #include "io/buffer.h"
> +#include "trace.h"
>  
>  #define QIO_BUFFER_MIN_INIT_SIZE 4096
>  
> @@ -37,6 +38,7 @@ void qio_buffer_reserve(QIOBuffer *buffer, size_t len)
>          buffer->capacity = pow2ceil(buffer->offset + len);
>          buffer->capacity = MAX(buffer->capacity, QIO_BUFFER_MIN_INIT_SIZE);
>          buffer->buffer = g_realloc(buffer->buffer, buffer->capacity);
> +        trace_qio_buffer_resize(buffer->name ?: "unnamed", buffer->capacity);
>      }
>  }
>  
> @@ -57,6 +59,7 @@ void qio_buffer_reset(QIOBuffer *buffer)
>  
>  void qio_buffer_free(QIOBuffer *buffer)
>  {
> +    trace_qio_buffer_free(buffer->name ?: "unnamed");
>      g_free(buffer->buffer);
>      g_free(buffer->name);
>      buffer->offset = 0;
> @@ -80,6 +83,9 @@ void qio_buffer_advance(QIOBuffer *buffer, size_t len)
>  
>  void qio_buffer_move_empty(QIOBuffer *to, QIOBuffer *from)
>  {
> +    trace_qio_buffer_move_empty(to->name ?: "unnamed",
> +                                from->offset,
> +                                from->name ?: "unnamed");
>      assert(to->offset == 0);
>  
>      g_free(to->buffer);
> @@ -99,6 +105,10 @@ void qio_buffer_move(QIOBuffer *to, QIOBuffer *from)
>          return;
>      }
>  
> +    trace_qio_buffer_move(to->name ?: "unnamed",
> +                          from->offset,
> +                          from->name ?: "unnamed");
> +
>      qio_buffer_reserve(to, from->offset);
>      qio_buffer_append(to, from->buffer, from->offset);
>  
> diff --git a/trace-events b/trace-events
> index 88a2f14..0f06b64 100644
> --- a/trace-events
> +++ b/trace-events
> @@ -1376,6 +1376,12 @@ spapr_iommu_new_table(uint64_t liobn, void *tcet, void *table, int fd) "liobn=%"
>  # hw/ppc/ppc.c
>  ppc_tb_adjust(uint64_t offs1, uint64_t offs2, int64_t diff, int64_t seconds) "adjusted from 0x%"PRIx64" to 0x%"PRIx64", diff %"PRId64" (%"PRId64"s)"
>  
> +# io/buffer.c
> +qio_buffer_resize(const char *buf, size_t len) "%s: len %zd"
> +qio_buffer_move_empty(const char *buf, size_t len, const char *from) "%s: %zd bytes from %s"
> +qio_buffer_move(const char *buf, size_t len, const char *from) "%s: %zd bytes from %s"
> +qio_buffer_free(const char *buf) "%s"
> +
>  # util/hbitmap.c
>  hbitmap_iter_skip_words(const void *hb, void *hbi, uint64_t pos, unsigned long cur) "hb %p hbi %p pos %"PRId64" cur 0x%lx"
>  hbitmap_reset(void *hb, uint64_t start, uint64_t count, uint64_t sbit, uint64_t ebit) "hb %p items %"PRIu64",%"PRIu64" bits %"PRIu64"..%"PRIu64

It might be a good idea to add the allocation size (aka capacity) when the buffer is freed:

diff --git a/io/buffer.c b/io/buffer.c
index 05425c2..60a96b0 100644
--- a/io/buffer.c
+++ b/io/buffer.c
@@ -59,7 +59,7 @@ void qio_buffer_reset(QIOBuffer *buffer)
 
 void qio_buffer_free(QIOBuffer *buffer)
 {
-    trace_qio_buffer_free(buffer->name ?: "unnamed");
+    trace_qio_buffer_free(buffer->name ?: "unnamed", buffer->capacity);
     g_free(buffer->buffer);
     g_free(buffer->name);
     buffer->offset = 0;
diff --git a/trace-events b/trace-events
index 0f06b64..53e096b 100644
--- a/trace-events
+++ b/trace-events
@@ -1380,7 +1380,7 @@ ppc_tb_adjust(uint64_t offs1, uint64_t offs2, int64_t diff, int64_t seconds) "ad
 qio_buffer_resize(const char *buf, size_t len) "%s: len %zd"
 qio_buffer_move_empty(const char *buf, size_t len, const char *from) "%s: %zd bytes from %s"
 qio_buffer_move(const char *buf, size_t len, const char *from) "%s: %zd bytes from %s"
-qio_buffer_free(const char *buf) "%s"
+qio_buffer_free(const char *buf, size_t len) "%s: capacity %zd"
 
 # util/hbitmap.c
 hbitmap_iter_skip_words(const void *hb, void *hbi, uint64_t pos, unsigned long cur) "hb %p hbi %p pos %"PRId64" cur 0x%lx"


This reveals that the buffers still increase to a reasonable size so it might still be an option to have some sort of shrinking logic:

3542@1443168337.727259:qio_buffer_free vnc-input/12: capacity 4096
3542@1443168337.727314:qio_buffer_free vnc-output/12: capacity 8388608
3542@1443168337.727935:qio_buffer_free vnc-ws_input/12: capacity 0
3542@1443168337.727960:qio_buffer_free vnc-ws_output/12: capacity 0
3542@1443168337.727978:qio_buffer_free vnc-zlib/12: capacity 0
3542@1443168337.728000:qio_buffer_free vnc-tight/12: capacity 16777216
3542@1443168337.729175:qio_buffer_free vnc-tight-zlib/12: capacity 32768
3542@1443168337.729376:qio_buffer_free vnc-tight-gradient/12: capacity 0
3542@1443168337.729395:qio_buffer_free vnc-tight-png/12: capacity 0
3542@1443168337.729409:qio_buffer_free vnc-zrle/12: capacity 0
3542@1443168337.729429:qio_buffer_free vnc-zrle-fb/12: capacity 0
3542@1443168337.729443:qio_buffer_free vnc-zrle-zlib/12: capacity 0
3542@1443168337.729459:qio_buffer_free vnc-jobs_buffer/12: capacity 0

Peter

  reply	other threads:[~2015-09-25  8:11 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-24  8:41 [Qemu-devel] [RfC PATCH 00/10] vnc buffer handling Gerd Hoffmann
2015-09-24  8:41 ` [Qemu-devel] [RfC PATCH 01/10] io/ makefile fluff Gerd Hoffmann
2015-09-24  8:42 ` [Qemu-devel] [RfC PATCH 02/10] io: pull Buffer code out of VNC module Gerd Hoffmann
2015-09-25  9:57   ` Peter Lieven
2015-09-24  8:42 ` [Qemu-devel] [RfC PATCH 03/10] vnc: make the Buffer capacity increase in powers of two Gerd Hoffmann
2015-09-24  8:42 ` [Qemu-devel] [RfC PATCH 04/10] io: add qio_buffer_init Gerd Hoffmann
2015-09-25  9:56   ` Peter Lieven
2015-09-24  8:42 ` [Qemu-devel] [RfC PATCH 05/10] io: add qio_buffer_move_empty Gerd Hoffmann
2015-09-25  9:56   ` Peter Lieven
2015-09-24  8:42 ` [Qemu-devel] [RfC PATCH 06/10] io: add qio_buffer_move Gerd Hoffmann
2015-09-25  9:57   ` Peter Lieven
2015-09-24  8:42 ` [Qemu-devel] [RfC PATCH 07/10] io: add qio_buffer tracing Gerd Hoffmann
2015-09-25  8:10   ` Peter Lieven [this message]
2015-09-24  8:42 ` [Qemu-devel] [RfC PATCH 08/10] name vnc buffers Gerd Hoffmann
2015-09-25  7:28   ` Peter Lieven
2015-09-25  7:58   ` Peter Lieven
2015-09-24  8:42 ` [Qemu-devel] [RfC PATCH 09/10] vnc: kill jobs queue buffer Gerd Hoffmann
2015-09-25  9:57   ` Peter Lieven
2015-09-24  8:42 ` [Qemu-devel] [RfC PATCH 10/10] vnc-jobs: move buffer reset, use new buffer move Gerd Hoffmann
2015-09-25  9:39   ` Peter Lieven
2015-09-24 16:25 ` [Qemu-devel] [RfC PATCH 00/10] vnc buffer handling Daniel P. Berrange
2015-09-25  9:56 ` Peter Lieven

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56050191.2020107@kamp.de \
    --to=pl@kamp.de \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).