qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] migration: Improve bandwidth estimation
@ 2011-03-31 20:30 Pierre Riteau
  2011-05-02 12:19 ` Pierre Riteau
  0 siblings, 1 reply; 3+ messages in thread
From: Pierre Riteau @ 2011-03-31 20:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Pierre Riteau

In the current migration code, bandwidth is estimated by measuring the
time spent in the ram_save_block loop and dividing by the number of sent
bytes. However, because of buffering, the time spent in this loop is
usually much less than the actual time required to send data on the
wire. Try to improve this by measuring the time spent between two calls
to ram_save_live instead.

Signed-off-by: Pierre Riteau <Pierre.Riteau@irisa.fr>
---
 arch_init.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch_init.c b/arch_init.c
index 0c09f91..7b822fe 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -175,6 +175,7 @@ static int ram_save_block(QEMUFile *f)
 }
 
 static uint64_t bytes_transferred;
+static int64_t prev_time;
 
 static ram_addr_t ram_save_remaining(void)
 {
@@ -254,6 +255,7 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)
     uint64_t bytes_transferred_last;
     double bwidth = 0;
     uint64_t expected_time = 0;
+    int64_t current_time;
 
     if (stage < 0) {
         cpu_physical_memory_set_dirty_tracking(0);
@@ -286,6 +288,8 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)
         /* Enable dirty memory tracking */
         cpu_physical_memory_set_dirty_tracking(1);
 
+        prev_time = qemu_get_clock_ns(rt_clock);
+
         qemu_put_be64(f, ram_bytes_total() | RAM_SAVE_FLAG_MEM_SIZE);
 
         QLIST_FOREACH(block, &ram_list.blocks, next) {
@@ -296,7 +300,6 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)
     }
 
     bytes_transferred_last = bytes_transferred;
-    bwidth = qemu_get_clock_ns(rt_clock);
 
     while (!qemu_file_rate_limit(f)) {
         int bytes_sent;
@@ -308,8 +311,10 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)
         }
     }
 
-    bwidth = qemu_get_clock_ns(rt_clock) - bwidth;
+    current_time = qemu_get_clock_ns(rt_clock);
+    bwidth = current_time - prev_time;
     bwidth = (bytes_transferred - bytes_transferred_last) / bwidth;
+    prev_time = current_time;
 
     /* if we haven't transferred anything this round, force expected_time to a
      * a very high value, but without crashing */
-- 
1.7.4.2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] migration: Improve bandwidth estimation
  2011-03-31 20:30 [Qemu-devel] [PATCH] migration: Improve bandwidth estimation Pierre Riteau
@ 2011-05-02 12:19 ` Pierre Riteau
  2011-09-14 17:17   ` Pierre Riteau
  0 siblings, 1 reply; 3+ messages in thread
From: Pierre Riteau @ 2011-05-02 12:19 UTC (permalink / raw)
  To: qemu-devel

Any comment on this patch?

On 31 mars 2011, at 22:30, Pierre Riteau wrote:

> In the current migration code, bandwidth is estimated by measuring the
> time spent in the ram_save_block loop and dividing by the number of sent
> bytes. However, because of buffering, the time spent in this loop is
> usually much less than the actual time required to send data on the
> wire. Try to improve this by measuring the time spent between two calls
> to ram_save_live instead.
> 
> Signed-off-by: Pierre Riteau <Pierre.Riteau@irisa.fr>
> ---
> arch_init.c |    9 +++++++--
> 1 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/arch_init.c b/arch_init.c
> index 0c09f91..7b822fe 100644
> --- a/arch_init.c
> +++ b/arch_init.c
> @@ -175,6 +175,7 @@ static int ram_save_block(QEMUFile *f)
> }
> 
> static uint64_t bytes_transferred;
> +static int64_t prev_time;
> 
> static ram_addr_t ram_save_remaining(void)
> {
> @@ -254,6 +255,7 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)
>     uint64_t bytes_transferred_last;
>     double bwidth = 0;
>     uint64_t expected_time = 0;
> +    int64_t current_time;
> 
>     if (stage < 0) {
>         cpu_physical_memory_set_dirty_tracking(0);
> @@ -286,6 +288,8 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)
>         /* Enable dirty memory tracking */
>         cpu_physical_memory_set_dirty_tracking(1);
> 
> +        prev_time = qemu_get_clock_ns(rt_clock);
> +
>         qemu_put_be64(f, ram_bytes_total() | RAM_SAVE_FLAG_MEM_SIZE);
> 
>         QLIST_FOREACH(block, &ram_list.blocks, next) {
> @@ -296,7 +300,6 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)
>     }
> 
>     bytes_transferred_last = bytes_transferred;
> -    bwidth = qemu_get_clock_ns(rt_clock);
> 
>     while (!qemu_file_rate_limit(f)) {
>         int bytes_sent;
> @@ -308,8 +311,10 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)
>         }
>     }
> 
> -    bwidth = qemu_get_clock_ns(rt_clock) - bwidth;
> +    current_time = qemu_get_clock_ns(rt_clock);
> +    bwidth = current_time - prev_time;
>     bwidth = (bytes_transferred - bytes_transferred_last) / bwidth;
> +    prev_time = current_time;
> 
>     /* if we haven't transferred anything this round, force expected_time to a
>      * a very high value, but without crashing */
> -- 
> 1.7.4.2
> 

-- 
Pierre Riteau -- PhD student, Myriads team, IRISA, Rennes, France
http://perso.univ-rennes1.fr/pierre.riteau/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] migration: Improve bandwidth estimation
  2011-05-02 12:19 ` Pierre Riteau
@ 2011-09-14 17:17   ` Pierre Riteau
  0 siblings, 0 replies; 3+ messages in thread
From: Pierre Riteau @ 2011-09-14 17:17 UTC (permalink / raw)
  To: qemu-devel

There is some discussion today on migration downtime so I try again: anyone with comments on this patch?

On 2 mai 2011, at 14:19, Pierre Riteau wrote:

> Any comment on this patch?
> 
> On 31 mars 2011, at 22:30, Pierre Riteau wrote:
> 
>> In the current migration code, bandwidth is estimated by measuring the
>> time spent in the ram_save_block loop and dividing by the number of sent
>> bytes. However, because of buffering, the time spent in this loop is
>> usually much less than the actual time required to send data on the
>> wire. Try to improve this by measuring the time spent between two calls
>> to ram_save_live instead.
>> 
>> Signed-off-by: Pierre Riteau <Pierre.Riteau@irisa.fr>
>> ---
>> arch_init.c |    9 +++++++--
>> 1 files changed, 7 insertions(+), 2 deletions(-)
>> 
>> diff --git a/arch_init.c b/arch_init.c
>> index 0c09f91..7b822fe 100644
>> --- a/arch_init.c
>> +++ b/arch_init.c
>> @@ -175,6 +175,7 @@ static int ram_save_block(QEMUFile *f)
>> }
>> 
>> static uint64_t bytes_transferred;
>> +static int64_t prev_time;
>> 
>> static ram_addr_t ram_save_remaining(void)
>> {
>> @@ -254,6 +255,7 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)
>>    uint64_t bytes_transferred_last;
>>    double bwidth = 0;
>>    uint64_t expected_time = 0;
>> +    int64_t current_time;
>> 
>>    if (stage < 0) {
>>        cpu_physical_memory_set_dirty_tracking(0);
>> @@ -286,6 +288,8 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)
>>        /* Enable dirty memory tracking */
>>        cpu_physical_memory_set_dirty_tracking(1);
>> 
>> +        prev_time = qemu_get_clock_ns(rt_clock);
>> +
>>        qemu_put_be64(f, ram_bytes_total() | RAM_SAVE_FLAG_MEM_SIZE);
>> 
>>        QLIST_FOREACH(block, &ram_list.blocks, next) {
>> @@ -296,7 +300,6 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)
>>    }
>> 
>>    bytes_transferred_last = bytes_transferred;
>> -    bwidth = qemu_get_clock_ns(rt_clock);
>> 
>>    while (!qemu_file_rate_limit(f)) {
>>        int bytes_sent;
>> @@ -308,8 +311,10 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)
>>        }
>>    }
>> 
>> -    bwidth = qemu_get_clock_ns(rt_clock) - bwidth;
>> +    current_time = qemu_get_clock_ns(rt_clock);
>> +    bwidth = current_time - prev_time;
>>    bwidth = (bytes_transferred - bytes_transferred_last) / bwidth;
>> +    prev_time = current_time;
>> 
>>    /* if we haven't transferred anything this round, force expected_time to a
>>     * a very high value, but without crashing */
>> -- 
>> 1.7.4.2
>> 
> 
> -- 
> Pierre Riteau -- PhD student, Myriads team, IRISA, Rennes, France
> http://perso.univ-rennes1.fr/pierre.riteau/
> 
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-09-14 17:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-31 20:30 [Qemu-devel] [PATCH] migration: Improve bandwidth estimation Pierre Riteau
2011-05-02 12:19 ` Pierre Riteau
2011-09-14 17:17   ` Pierre Riteau

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).