Received: from eggs.gnu.org ([208.118.235.92]:39284) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Talc7-0004wI-MG for qemu-devel@nongnu.org; Tue, 20 Nov 2012 06:03:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Talby-0004HB-2k for qemu-devel@nongnu.org; Tue, 20 Nov 2012 06:03:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47789) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Talbx-0004Gp-Pi for qemu-devel@nongnu.org; Tue, 20 Nov 2012 06:03:25 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qAKB3Ppe014493 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 20 Nov 2012 06:03:25 -0500 From: Juan Quintela In-Reply-To: <1353342180-20392-1-git-send-email-pbonzini@redhat.com> (Paolo Bonzini's message of "Mon, 19 Nov 2012 17:23:00 +0100") References: <1353342180-20392-1-git-send-email-pbonzini@redhat.com> Date: Tue, 20 Nov 2012 12:03:18 +0100 Message-ID: <87wqxgcz9l.fsf@elfo.mitica> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH] migration: fix rate limiting Reply-To: quintela@redhat.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: owasserm@redhat.com, qemu-devel@nongnu.org Paolo Bonzini wrote: > buffered_rate_limit is called to prevent the RAM migration callback > from putting too much data in the buffer. So it has to check against > the amount of data currently in the buffer, not against the amount > of data that has been transferred so far. > > s->bytes_xfer is used to communicate between successive calls of > buffered_put_buffer. Buffered_rate_tick resets it every now and > then to prevent moving too much buffered data to the socket at > once. However, its value does not matter for the producer of the > data. > > Here is the result for migrating an idle guest with 3GB of memory > and ~360MB of non-zero memory: > > migrate_set_speed Before After > ------------------------------------------------------------ > default (32MB/sec) ~3 sec ~13 sec > infinite (10GB/sec) ~3 sec ~3 sec > > Note that before this patch, QEMU is transferring of 100 MB/sec > despite the rate limiting. This patch is wrong O;-) That don't mean that current code is right. We have 4 variables: - xfer_limit: how much we are allowed to send each 100ms (in bytes) - buffer_capacity: the size of the buffer that we are using - buffer_size: the amount of the previous buffer that we are using buffer_size < buffer_capacity, or we are doing something wrong. - bytes_xfer: How many bytes we have transfered since last 100ms timer. And how this work: - we have an input handler that copies stuff from RAM to buffer it stops when we have sent more that xfer_limit on this period (each 100ms) - we have another handler that is run each 100ms, and this one sent anything that is on the buffer, and reset bytes_xfer to zero. WHat you have done is just telling that in the 1st input handler, that we always have size on the buffer for it, so that we are not doing any rate limiting at all. Note that the migration_thread code changes all this code, and there, the statistics are handled much better. It is very strange that buffer_capacity is bigger that xfer_limit (it could happen, but it is very unusual), and then what you have done there is just disabling rate limiting altogether. So .... NACK > > Signed-off-by: Paolo Bonzini > --- > buffered_file.c | 2 +- > 1 file modificato, 1 inserzione(+). 1 rimozione(-) > > diff --git a/buffered_file.c b/buffered_file.c > index bd0f61d..46cd591 100644 > --- a/buffered_file.c > +++ b/buffered_file.c > @@ -193,7 +193,7 @@ static int buffered_rate_limit(void *opaque) > if (s->freeze_output) > return 1; > > - if (s->bytes_xfer > s->xfer_limit) o> + if (s->buffer_size > s->xfer_limit) > return 1; > > return 0;