migration: keep log rate steady if polling gets more frequent

Either we're done in a few seconds anyway, or if the VM dirties lots
of pages we need quite a bit of time, and then it does not help to
output roughly the same status 10 times a second...

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2021-04-19 22:01:05 +02:00
parent 0fca250af0
commit b68a957b2e

View File

@ -1101,6 +1101,8 @@ sub phase2 {
# reduce sleep if remainig memory is lower than the average transfer speed # reduce sleep if remainig memory is lower than the average transfer speed
$usleep = 100_000 if $avglstat && $rem < $avglstat; $usleep = 100_000 if $avglstat && $rem < $avglstat;
# also reduce loggin if we poll more frequent
my $should_log = $usleep > 100_000 ? 1 : ($i % 10) == 0;
my $total_h = render_bytes($total, 1); my $total_h = render_bytes($total, 1);
my $transferred_h = render_bytes($trans, 1); my $transferred_h = render_bytes($trans, 1);
@ -1113,7 +1115,7 @@ sub phase2 {
$progress .= ", VM dirties lots of memory: $dirty_rate_h/s"; $progress .= ", VM dirties lots of memory: $dirty_rate_h/s";
} }
$self->log('info', "migration $status, $progress"); $self->log('info', "migration $status, $progress") if $should_log;
my $xbzrle = $stat->{"xbzrle-cache"} || {}; my $xbzrle = $stat->{"xbzrle-cache"} || {};
my ($xbzrlebytes, $xbzrlepages) = $xbzrle->@{'bytes', 'pages'}; my ($xbzrlebytes, $xbzrlepages) = $xbzrle->@{'bytes', 'pages'};
@ -1127,7 +1129,7 @@ sub phase2 {
$msg .= ", overflow $xbzrle->{overflow}" if $xbzrle->{overflow}; $msg .= ", overflow $xbzrle->{overflow}" if $xbzrle->{overflow};
$self->log('info', "xbzrle: $msg"); $self->log('info', "xbzrle: $msg") if $should_log;
} }
if (($lastrem && $rem > $lastrem) || ($rem == 0)) { if (($lastrem && $rem > $lastrem) || ($rem == 0)) {