From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58549) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zs8sb-0006bc-8B for qemu-devel@nongnu.org; Fri, 30 Oct 2015 08:34:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zs8sX-0000s0-Gx for qemu-devel@nongnu.org; Fri, 30 Oct 2015 08:34:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59609) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zs8sX-0000rv-Ba for qemu-devel@nongnu.org; Fri, 30 Oct 2015 08:33:57 -0400 Date: Fri, 30 Oct 2015 21:33:47 +0900 From: "Daniel P. Berrange" Message-ID: <20151030123347.GS20961@redhat.com> References: <1446203414-4013-1-git-send-email-kraxel@redhat.com> <1446203414-4013-20-git-send-email-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1446203414-4013-20-git-send-email-kraxel@redhat.com> Subject: Re: [Qemu-devel] [PATCH 19/19] buffer: allow a buffer to shrink gracefully Reply-To: "Daniel P. Berrange" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: pl@kamp.de, qemu-devel@nongnu.org On Fri, Oct 30, 2015 at 12:10:14PM +0100, Gerd Hoffmann wrote: > From: Peter Lieven > > the idea behind this patch is to allow the buffer to shrink, but > make this a seldom operation. The buffers average size is measured > exponentionally smoothed with am alpha of 1/128. s/am/an/ > > Signed-off-by: Peter Lieven > Signed-off-by: Gerd Hoffmann > --- > include/qemu/buffer.h | 1 + > util/buffer.c | 34 ++++++++++++++++++++++++++++------ > 2 files changed, 29 insertions(+), 6 deletions(-) > diff --git a/util/buffer.c b/util/buffer.c > index fe5a44e..5461f86 100644 > --- a/util/buffer.c > +++ b/util/buffer.c > @@ -23,6 +23,7 @@ > > #define BUFFER_MIN_INIT_SIZE 4096 > #define BUFFER_MIN_SHRINK_SIZE 65536 > +#define BUFFER_AVG_SIZE_SHIFT 7 > > static size_t buffer_req_size(Buffer *buffer, size_t len) > { > @@ -37,6 +38,11 @@ static void buffer_adj_size(Buffer *buffer, size_t len) > buffer->buffer = g_realloc(buffer->buffer, buffer->capacity); > trace_buffer_resize(buffer->name ?: "unnamed", > old, buffer->capacity); > + > + /* make it even harder for the buffer to shrink, reset average size > + * to currenty capacity if it is larger than the average. */ s/currenty/current/ Reviewed-by: Daniel P. Berrange Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|