On Fri, Oct 30, 2015 at 12:10:14PM +0100, Gerd Hoffmann wrote: > From: Peter Lieven <p...@kamp.de> > > 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 <p...@kamp.de> > Signed-off-by: Gerd Hoffmann <kra...@redhat.com> > --- > 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 <berra...@redhat.com> 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 :|