Tomas Jelinek has uploaded a new change for review.

Change subject: migrations: enhance legacy downtime alg
......................................................................

migrations: enhance legacy downtime alg

This patch contains the following enhancements of the legacy downtime thread:

- start the downtime thread in pause mode and unpause it only after first
  iteration since during first iteration it does not make sense to do any
  adjustments since we don't know if the migration will be stalling or not

- change the way and params the wait for next step is calculated so:
  - for smaller VMs (up to 2048 MiB) the wait is calculated as before (e.g. the
    smaller the memory is, the smaller the wait is)
  - for larger VMs the wait is 60s (otherwise it grows to very large numbers
    soon so this is the higer limit)

Change-Id: I5d18a77c91a1344110afef1577e310faab3ffe5b
Signed-off-by: Tomas Jelinek <tjeli...@redhat.com>
---
M lib/vdsm/config.py.in
M vdsm/virt/migration.py
2 files changed, 35 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/61/56561/1

diff --git a/lib/vdsm/config.py.in b/lib/vdsm/config.py.in
index 77a1365..58f22bd 100644
--- a/lib/vdsm/config.py.in
+++ b/lib/vdsm/config.py.in
@@ -110,7 +110,7 @@
             'liveness of migration, set to a very high value, such as '
             '600000.'),
 
-        ('migration_downtime_delay', '20',
+        ('migration_downtime_delay', '100',
             'This value is used on the source host to define the delay before '
             'setting/increasing the downtime of a migration. '
             'The value is per GiB of RAM. A minimum of twice this value is '
diff --git a/vdsm/virt/migration.py b/vdsm/virt/migration.py
index 48f3ce3..b87b624 100644
--- a/vdsm/virt/migration.py
+++ b/vdsm/virt/migration.py
@@ -454,6 +454,8 @@
             int(self._downtime),
             config.getint('vars', 'migration_downtime_steps'))
 
+        self._monitorThread.set_downtime_thread(downtimeThread)
+
         with utils.running(downtimeThread):
             with utils.running(self._monitorThread):
                 # we need to support python 2.6, so two nested with-s.
@@ -496,21 +498,29 @@
         self._downtime = downtime
         self._steps = steps
         self._stop = threading.Event()
+        self._pause = threading.Lock()
 
         delay_per_gib = config.getint('vars', 'migration_downtime_delay')
         memSize = int(vm.conf['memSize'])
-        self._wait = (delay_per_gib * max(memSize, 2048) + 1023) / 1024
+        self._wait = min(delay_per_gib * (memSize + 1023) / 1024 / 
self._steps, 60)
+        if self._steps > 1:
+            self._exponentialDowntimes = list(exponential_downtime(downtime, 
self._steps))
+        else:
+            self._exponentialDowntimes = [downtime]
 
         self.daemon = True
+        # to start paused
+        self._pause.acquire()
 
     def run(self):
+        # the lock is already taken so started in pause mode until someone 
releases it
+        self._pause.acquire()
+
         self._vm.log.debug('migration downtime thread started (%i steps)',
                            self._steps)
 
-        if self._steps > 1:
-            self._set_downtime_by_steps(self._downtime)
-        else:
-            self._set_downtime(self._downtime)
+        if len(self._exponentialDowntimes) >= 1:
+            self._set_downtime_by_steps()
 
         self._vm.log.debug('migration downtime thread exiting')
 
@@ -518,14 +528,20 @@
         self._vm.log.debug('stopping migration downtime thread')
         self._stop.set()
 
-    def _set_downtime_by_steps(self, max_downtime):
-        for downtime in exponential_downtime(max_downtime, self._steps):
+    def start_execution(self):
+        self._pause.release()
+
+    def set_first_downtime(self):
+        self._set_downtime(self._exponentialDowntimes.pop(0))
+
+    def _set_downtime_by_steps(self):
+        for downtime in self._exponentialDowntimes:
             if self._stop.isSet():
                 break
 
             self._set_downtime(downtime)
 
-            self._stop.wait(self._wait / self._steps)
+            self._stop.wait(self._wait)
 
     def _set_downtime(self, downtime):
         self._vm.log.debug('setting migration downtime to %d', downtime)
@@ -576,6 +592,8 @@
         iterationCount = 0
 
         self._execute_init(self._conv_schedule['init'])
+        if not self._use_conv_schedule:
+            self._downtimeThread.set_first_downtime()
 
         while not self._stop.isSet():
             self._stop.wait(self._MIGRATION_MONITOR_INTERVAL)
@@ -608,6 +626,11 @@
                 self._vm.log.debug('new iteration detected: %i', 
iterationCount)
                 if self._use_conv_schedule:
                     self._next_action(iterationCount)
+                elif iterationCount == 1:
+                    # it does not make sense to do any adjustments before
+                    # first iteration finishes => unpause the thread only
+                    # after a new iteration is detected
+                    self._downtimeThread.start_execution()
 
             lastDataRemaining = prog.data_remaining
 
@@ -636,6 +659,9 @@
         self._vm.log.debug('stopping migration monitor thread')
         self._stop.set()
 
+    def set_downtime_thread(self, downtimeThread):
+        self._downtimeThread = downtimeThread
+
     def _next_action(self, stalling):
         head = self._conv_schedule['stalling'][0]
 


-- 
To view, visit https://gerrit.ovirt.org/56561
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5d18a77c91a1344110afef1577e310faab3ffe5b
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Tomas Jelinek <tjeli...@redhat.com>
_______________________________________________
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to