migration: Improve bandwidth estimation
PATCH 1/1 migration: Improve bandwidth estimation
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.
--- arch_init.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-)
arch_init.c +7 -2
@@ -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 */
Signature · 1 line
1.7.4.2
Any comment on this patch?
Quoted 64 lines · Pierre Riteau
In the current migration code, bandwidth is estimated by measuring the time spent in the
ram_save_blockloop 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 toram_save_liveinstead.Signed-off-by Pierre Riteau <[email protected]>---
arch_init.c| 9 +++++++--1 files changed, 7 insertions(+), 2 deletions(-)arch_init.c +7
-2@@ -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 */ Signature · 1 line
1.7.4.2
Signature · 2 lines
Pierre Riteau -- PhD student, Myriads team, IRISA, Rennes, France http://perso.univ-rennes1.fr/pierre.riteau/
There is some discussion today on migration downtime so I try again: anyone with comments on this patch?
Quoted 74 lines · Pierre Riteau
Any comment on this patch?
Quoted 64 lines · Pierre Riteau
In the current migration code, bandwidth is estimated by measuring the time spent in the
ram_save_blockloop 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 toram_save_liveinstead.Signed-off-by Pierre Riteau <[email protected]>---
arch_init.c| 9 +++++++--1 files changed, 7 insertions(+), 2 deletions(-)arch_init.c +7
-2@@ -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 */ Signature · 1 line
1.7.4.2Signature · 2 lines
Pierre Riteau -- PhD student, Myriads team, IRISA, Rennes, France http://perso.univ-rennes1.fr/pierre.riteau/