Skip to contentSkip to conversation

A migration performance testing framework

PATCH Superseded Daniel P. Berrange 4 participants 13 messages May 5, 2016 – May 23, 2016

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#1 lore raw

PATCH 1/6 scripts: add __init__.py file to scripts/qmp/

In reply to Daniel P. Berrange

When searching for modules to load, python will ignore any sub-directory which does not contain __init__.py. This means that both scripts and scripts/qmp/ have to be explicitly added to the python path. By adding a __init__.py file to scripts/qmp, we only need add scripts/ to the python path and can then simply do 'from qmp import qmp' to load scripts/qmp/qmp.py.

---
 scripts/qmp/__init__.py | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 scripts/qmp/__init__.py
scripts/qmp/__init__.py new file +0 -0
new file mode 100644
index 0000000..e69de29
Signature · 1 line
2.5.5
#0 lore raw

cover A migration performance testing framework

This series of patches provides a framework for testing migration performance characteristics. The motivating factor for this is planning that is underway in OpenStack wrt making use of QEMU migration features such as compression, auto-converge and post-copy. The primary aim for OpenStack is to have Nova autonomously manage migration features & tunables to maximise chances that migration will complete. The problem faced is figuring out just which QEMU migration features are "best" suited to our needs. This means we want data on how well they are able to ensure completion of a migration, against the host resources used and the impact on the guest workload performance.

The test framework produced here takes a pathelogical guest workload (every CPU just burning 100% of time xor'ing every byte of guest memory with random data). This is quite a pessimistic test because most guest workloads are not giong to be this heavy on memory writes, and their data won't be uniformly random and so will be able to compress better than this test does.

With this worst case guest, I have produced a set of tests using UNIX socket, TCP localhost, TCP remote and RDMA remote socket transports, with both a 1 GB RAM + 1 CPU guest and a 8 GB RAM + 4 CPU guest.

The TCP/RDMA remote host tests were run over a 10-GiG-E network interface.

I have put the results online to view here:

https://berrange.fedorapeople.org/qemu-mig-test-2016-05-05/

The charts here are showing two core sets of data:

- The guest CPU performance. The left axis is showing the time in milliseconds required to xor 1 GB of memory. This is shown per-guest CPU and combined all CPUs.

- The host CPU utilization. The right axis is showing the overall QEMU process CPU utilization, and the per-VCPU utilization.

Note that the charts are interactive - you can turn on/off each plot line and zoom in by selecting regions on the chart.

Some interesting things that I have observed with this

- At the start of each iteration of migration there is a distinct drop in guest CPU performance as shown by a spike in the guest CPU time lines. Performance would drop from 200ms/GB to 400ms/GB. Presumably this is related to QEMU recalculating the dirty bitmap for the guest RAM. See the spikes in the green line in:

    https://berrange.fedorapeople.org/qemu-mig-test-2016-05-05/tcp-remote-1gb-1cpu/post-copy-bandwidth/post-copy-bw-1gbs.html

- For the larger sized guests, the auto-converge code has to throttle the guest to as much as 90% or more before it is able to meet the 500ms max downtime value

    https://berrange.fedorapeople.org/qemu-mig-test-2016-05-05/tcp-remote-1gb-1cpu/auto-converge-bandwidth/auto-converge-bw-1gbs.html

Even then I often saw tests aborting as they hit the max number of iterations I permitted (30 iters max)

    https://berrange.fedorapeople.org/qemu-mig-test-2016-05-05/tcp-remote-8gb-4cpu/auto-converge-bandwidth/auto-converge-bw-10gbs.html

- MT compression is actively harmful to chances of successful migration when the guest RAM is not compression friendly. My work load is worst case since it is splattering RAM with totally random bytes. The MT compression is dramatically increasing the time for each iteration as we bottleneck on CPU compression speed, leaving the network largely idle. This causes migration which would have completed without compression, to fail. It also burns huge amounts of host CPU time

     https://berrange.fedorapeople.org/qemu-mig-test-2016-05-05/tcp-remote-1gb-1cpu/compr-mt/compr-mt-threads-4.html

- XBZRLE compression did not have as much of a CPU peformance penalty on the host as MT comprssion, but also did not help migration to actually complete. Again this is largely due to the workload being the worst case scenario with random bytes. The downside is obviously the potentially significant memory overhead on the host due to the cache sizing

    https://berrange.fedorapeople.org/qemu-mig-test-2016-05-05/tcp-remote-1gb-1cpu/compr-xbzrle/compr-xbzrle-cache-50.html

- Post-copy, by its very nature, obviously ensured that the migraton would complete. While post-copy was running in pre-copy mode there was a somewhat chaotic small impact on guest CPU performance, causing performance to periodically oscillate between 400ms/GB and 800ms/GB. This is less than the impact at the start of each migration iteration which was 1000ms/GB in this test. There was also a massive penalty at time of switchover from pre to post copy, as to be expected. The migration completed in post-copy phase quite quickly though. For this workload, number of iterations in pre-copy mode before switching to post-copy did not have much impact. I expect a less extreme workload would have shown more interesting results wrt number of iterations of pre-copy:

    https://berrange.fedorapeople.org/qemu-mig-test-2016-05-05/tcp-remote-8gb-4cpu/post-copy-iters.html

Overall, if we're looking for a solution that can guarantee completion under the most extreme guest workload, then only post-copy & autoconverge appear upto the job.

The MT compression is seriously harmful to migration and has severe CPU overhead. The XBZRLE compression is moderatly harmful to migration and has potentilly severa memory overhead for large cache sizes to make it useful.

While auto-converge can ensure that guest migration completes, it has a pretty significantly long term impact on guest CPU performance to achieve this. ie the guest spends a long time in pre-copy mode with its CPUs very dramatically throttled down. The level of throttling required makes one wonder whether it is worth using, against simply pausing the guest workload. The latter has a hard blackout period, but over a quite short time frame if network speed is fast.

The post-copy code does have an impact on guest performance while in pre copy mode, vs a plain migration. It also has a fairly high spike when in post-copy mode, but this last for a pretty short time. As compared to auto-converge, it is able to ensure the migration completes in a finite time without having a prolonged impact on guest CPU performance. The penalty during the post-copy phase is on a par with the penalty impose by auto-converge when it has to throttle to 90%+.

Overall, in the context of a worst case guest workload, it appears that post-copy is the clear winning strategy ensuring completion of migration without imposing an long duration penalty on guest peformance. If the risk of failure from post-copy is unacceptable then auto-converge is a good fallback option, if the long duration guest CPU penalty can be accepted.

The compression options are only worth using if the host has free CPU resources, and the guest RAM is believed to be compression friendly, as they steal significant CPU time away from guests in order to run compression, often with a negative impact on migration completion chances.

Looking at migration in general, even with a 10-GiG-E NIC and RDMA transport it is possible for a single guest to provide a workload that will saturate the network during migration & thus prevent completion. Based on this, there is little point in attempting to run migrations in parallel on the same host, unless multiple NICs are available, as parallel migrations would reduce the chances of either one ever completing. Better reliability & faster overall completion would likely be achieved by fully serializing migration operations per host.

There is clearly scope for more investigation here, in particular

- Produce some alternative guest workloads that try to present a more "average" scenario workload, instead of the worst-case. These would likely allow compression to have some positive impact.

- Try various combinations of strategies. For example, combining post-copy and auto-converge at the same time, or compression combined with either post-copy or auto-converge.

- Investigate block migration performance too, with NBD migration server.

- Investigate effect of dynamically changing max downtime value during migration, rather than using a fixed 500ms value.

Daniel P. Berrange (6):
scripts: add __init__.py file to scripts/qmp/
scripts: add a 'debug' parameter to QEMUMonitorProtocol
scripts: refactor the VM class in iotests for reuse
scripts: set timeout when waiting for qemu monitor connection
scripts: ensure monitor socket has SO_REUSEADDR set
tests: introduce a framework for testing migration performance

 configure                               |   2 +
 scripts/qemu.py                         | 202 +++++++++++
 scripts/qmp/__init__.py                 |   0
 scripts/qmp/qmp.py                      |  15 +-
 scripts/qtest.py                        |  34 ++
 tests/Makefile                          |  12 +
 tests/migration/.gitignore              |   2 +
 tests/migration/guestperf-batch.py      |  26 ++
 tests/migration/guestperf-plot.py       |  26 ++
 tests/migration/guestperf.py            |  27 ++
 tests/migration/guestperf/__init__.py   |   0
 tests/migration/guestperf/comparison.py | 124 +++++++
 tests/migration/guestperf/engine.py     | 439 ++++++++++++++++++++++
 tests/migration/guestperf/hardware.py   |  62 ++++
 tests/migration/guestperf/plot.py       | 623 ++++++++++++++++++++++++++++++++
 tests/migration/guestperf/progress.py   | 117 ++++++
 tests/migration/guestperf/report.py     |  98 +++++
 tests/migration/guestperf/scenario.py   |  95 +++++
 tests/migration/guestperf/shell.py      | 255 +++++++++++++
 tests/migration/guestperf/timings.py    |  55 +++
 tests/migration/stress.c                | 367 +++++++++++++++++++
 tests/qemu-iotests/iotests.py           | 135 +------
 22 files changed, 2583 insertions(+), 133 deletions(-)
 create mode 100644 scripts/qemu.py
 create mode 100644 scripts/qmp/__init__.py
 create mode 100644 tests/migration/.gitignore
 create mode 100755 tests/migration/guestperf-batch.py
 create mode 100755 tests/migration/guestperf-plot.py
 create mode 100755 tests/migration/guestperf.py
 create mode 100644 tests/migration/guestperf/__init__.py
 create mode 100644 tests/migration/guestperf/comparison.py
 create mode 100644 tests/migration/guestperf/engine.py
 create mode 100644 tests/migration/guestperf/hardware.py
 create mode 100644 tests/migration/guestperf/plot.py
 create mode 100644 tests/migration/guestperf/progress.py
 create mode 100644 tests/migration/guestperf/report.py
 create mode 100644 tests/migration/guestperf/scenario.py
 create mode 100644 tests/migration/guestperf/shell.py
 create mode 100644 tests/migration/guestperf/timings.py
 create mode 100644 tests/migration/stress.c
Signature · 1 line
2.5.5
#2 lore raw

PATCH 2/6 scripts: add a 'debug' parameter to QEMUMonitorProtocol

Add a 'debug' parameter to the QEMUMonitorProtocol class which will cause it to print out all JSON strings on sys.stderr

---
 scripts/qmp/qmp.py | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
scripts/qmp/qmp.py +11 -2
index 779332f..70e927e 100644
@@ -11,6 +11,7 @@
 import json
 import errno
 import socket
+import sys
 
 class QMPError(Exception):
     pass
@@ -25,7 +26,7 @@ class QMPTimeoutError(QMPError):
     pass
 
 class QEMUMonitorProtocol:
-    def __init__(self, address, server=False):
+    def __init__(self, address, server=False, debug=False):
         """
         Create a QEMUMonitorProtocol class.
 
@@ -39,6 +40,7 @@ class QEMUMonitorProtocol:
         """
         self.__events = []
         self.__address = address
+        self._debug = debug
         self.__sock = self.__get_sock()
         if server:
             self.__sock.bind(self.__address)
@@ -68,6 +70,8 @@ class QEMUMonitorProtocol:
                 return
             resp = json.loads(data)
             if 'event' in resp:
+                if self._debug:
+                    print >>sys.stderr, "QMP:<<< %s" % resp
                 self.__events.append(resp)
                 if not only_event:
                     continue
@@ -148,13 +152,18 @@ class QEMUMonitorProtocol:
         @return QMP response as a Python dict or None if the connection has
                 been closed
         """
+        if self._debug:
+            print >>sys.stderr, "QMP:>>> %s" % qmp_cmd
         try:
             self.__sock.sendall(json.dumps(qmp_cmd))
         except socket.error as err:
             if err[0] == errno.EPIPE:
                 return
             raise socket.error(err)
-        return self.__json_read()
+        resp = self.__json_read()
+        if self._debug:
+            print >>sys.stderr, "QMP:<<< %s" % resp
+        return resp
 
     def cmd(self, name, args=None, id=None):
         """
Signature · 1 line
2.5.5
#3 lore raw

PATCH 3/6 scripts: refactor the VM class in iotests for reuse

In reply to Daniel P. Berrange

The iotests module has a python class for controlling QEMU processes. Pull the generic functionality out of this file and create a scripts/qemu.py module containing a QEMUMachine class. Put the QTest integration support into a subclass QEMUQtestMachine.

---
 scripts/qemu.py               | 202 ++++++++++++++++++++++++++++++++++++++++++
 scripts/qtest.py              |  34 +++++++
 tests/qemu-iotests/iotests.py | 135 +---------------------------
 3 files changed, 240 insertions(+), 131 deletions(-)
 create mode 100644 scripts/qemu.py
scripts/qemu.py new file +202 -0
new file mode 100644
index 0000000..9cdad24
@@ -0,0 +1,202 @@
+# QEMU library
+#
+# Copyright (C) 2015-2016 Red Hat Inc.
+# Copyright (C) 2012 IBM Corp.
+#
+# Authors:
+#  Fam Zheng <[email protected]>
+#
+# This work is licensed under the terms of the GNU GPL, version 2.  See
+# the COPYING file in the top-level directory.
+#
+# Based on qmp.py.
+#
+
+import errno
+import string
+import os
+import sys
+import subprocess
+import qmp.qmp
+
+
+class QEMUMachine(object):
+    '''A QEMU VM'''
+
+    def __init__(self, binary, args=[], wrapper=[], name=None, test_dir="/var/tmp",
+                 monitor_address=None, debug=False):
+        if name is None:
+            name = "qemu-%d" % os.getpid()
+        if monitor_address is None:
+            monitor_address = os.path.join(test_dir, name + "-monitor.sock")
+        self._monitor_address = monitor_address
+        self._qemu_log_path = os.path.join(test_dir, name + ".log")
+        self._popen = None
+        self._binary = binary
+        self._args = args
+        self._wrapper = wrapper
+        self._events = []
+        self._iolog = None
+        self._debug = debug
+
+    # This can be used to add an unused monitor instance.
+    def add_monitor_telnet(self, ip, port):
+        args = 'tcp:%s:%d,server,nowait,telnet' % (ip, port)
+        self._args.append('-monitor')
+        self._args.append(args)
+
+    def add_fd(self, fd, fdset, opaque, opts=''):
+        '''Pass a file descriptor to the VM'''
+        options = ['fd=%d' % fd,
+                   'set=%d' % fdset,
+                   'opaque=%s' % opaque]
+        if opts:
+            options.append(opts)
+
+        self._args.append('-add-fd')
+        self._args.append(','.join(options))
+        return self
+
+    def send_fd_scm(self, fd_file_path):
+        # In iotest.py, the qmp should always use unix socket.
+        assert self._qmp.is_scm_available()
+        bin = socket_scm_helper
+        if os.path.exists(bin) == False:
+            print "Scm help program does not present, path '%s'." % bin
+            return -1
+        fd_param = ["%s" % bin,
+                    "%d" % self._qmp.get_sock_fd(),
+                    "%s" % fd_file_path]
+        devnull = open('/dev/null', 'rb')
+        p = subprocess.Popen(fd_param, stdin=devnull, stdout=sys.stdout,
+                             stderr=sys.stderr)
+        return p.wait()
+
+    @staticmethod
+    def _remove_if_exists(path):
+        '''Remove file object at path if it exists'''
+        try:
+            os.remove(path)
+        except OSError as exception:
+            if exception.errno == errno.ENOENT:
+                return
+            raise
+
+    def get_pid(self):
+        if not self._popen:
+            return None
+        return self._popen.pid
+
+    def _load_io_log(self):
+        with open(self._qemu_log_path, "r") as fh:
+            self._iolog = fh.read()
+
+    def _base_args(self):
+        if isinstance(self._monitor_address, tuple):
+            moncdev = "socket,id=mon,host=%s,port=%s" % (
+                self._monitor_address[0],
+                self._monitor_address[1])
+        else:
+            moncdev = 'socket,id=mon,path=%s' % self._monitor_address
+        return ['-chardev', moncdev,
+                '-mon', 'chardev=mon,mode=control',
+                '-display', 'none', '-vga', 'none']
+
+    def _pre_launch(self):
+        self._qmp = qmp.qmp.QEMUMonitorProtocol(self._monitor_address, server=True,
+                                                debug=self._debug)
+
+    def _post_launch(self):
+        self._qmp.accept()
+
+    def _post_shutdown(self):
+        if not isinstance(self._monitor_address, tuple):
+            self._remove_if_exists(self._monitor_address)
+        self._remove_if_exists(self._qemu_log_path)
+
+    def launch(self):
+        '''Launch the VM and establish a QMP connection'''
+        devnull = open('/dev/null', 'rb')
+        qemulog = open(self._qemu_log_path, 'wb')
+        try:
+            self._pre_launch()
+            args = self._wrapper + [self._binary] + self._base_args() + self._args
+            self._popen = subprocess.Popen(args, stdin=devnull, stdout=qemulog,
+                                           stderr=subprocess.STDOUT, shell=False)
+            self._post_launch()
+        except:
+            if self._popen:
+                self._popen.kill()
+            self._load_io_log()
+            self._post_shutdown()
+            self._popen = None
+            raise
+
+    def shutdown(self):
+        '''Terminate the VM and clean up'''
+        if not self._popen is None:
+            try:
+                self._qmp.cmd('quit')
+                self._qmp.close()
+            except:
+                self._popen.kill()
+
+            exitcode = self._popen.wait()
+            if exitcode < 0:
+                sys.stderr.write('qemu received signal %i: %s\n' % (-exitcode, ' '.join(self._args)))
+            self._load_io_log()
+            self._post_shutdown()
+            self._popen = None
+
+    underscore_to_dash = string.maketrans('_', '-')
+    def qmp(self, cmd, conv_keys=True, **args):
+        '''Invoke a QMP command and return the result dict'''
+        qmp_args = dict()
+        for k in args.keys():
+            if conv_keys:
+                qmp_args[k.translate(self.underscore_to_dash)] = args[k]
+            else:
+                qmp_args[k] = args[k]
+
+        return self._qmp.cmd(cmd, args=qmp_args)
+
+    def command(self, cmd, conv_keys=True, **args):
+        reply = self.qmp(cmd, conv_keys, **args)
+        if reply is None:
+            raise Exception("Monitor is closed")
+        if "error" in reply:
+            raise Exception(reply["error"]["desc"])
+        return reply["return"]
+
+    def get_qmp_event(self, wait=False):
+        '''Poll for one queued QMP events and return it'''
+        if len(self._events) > 0:
+            return self._events.pop(0)
+        return self._qmp.pull_event(wait=wait)
+
+    def get_qmp_events(self, wait=False):
+        '''Poll for queued QMP events and return a list of dicts'''
+        events = self._qmp.get_events(wait=wait)
+        events.extend(self._events)
+        del self._events[:]
+        self._qmp.clear_events()
+        return events
+
+    def event_wait(self, name, timeout=60.0, match=None):
+        # Search cached events
+        for event in self._events:
+            if (event['event'] == name) and event_match(event, match):
+                self._events.remove(event)
+                return event
+
+        # Poll for new events
+        while True:
+            event = self._qmp.pull_event(wait=timeout)
+            if (event['event'] == name) and event_match(event, match):
+                return event
+            self._events.append(event)
+
+        return None
+
+    def get_log(self):
+        return self._iolog
scripts/qtest.py +34 -0
index a971445..03bc7f6 100644
@@ -13,6 +13,11 @@
 
 import errno
 import socket
+import string
+import os
+import subprocess
+import qmp.qmp
+import qemu
 
 class QEMUQtestProtocol(object):
     def __init__(self, address, server=False):
@@ -69,3 +74,32 @@ class QEMUQtestProtocol(object):
 
     def settimeout(self, timeout):
         self._sock.settimeout(timeout)
+
+
+class QEMUQtestMachine(qemu.QEMUMachine):
+    '''A QEMU VM'''
+
+    def __init__(self, binary, args=[], name=None, test_dir="/var/tmp"):
+        super(self, QEMUQtestMachine).__init__(binary, args, name, test_dir)
+        self._qtest_path = os.path.join(test_dir, name + "-qtest.sock")
+
+    def _base_args(self):
+        args = super(self, QEMUQtestMachine)._base_args()
+        args.extend(['-qtest', 'unix:path=' + self._qtest_path])
+        return args
+
+    def _pre_launch(self):
+        super(self, QEMUQtestMachine)._pre_launch()
+        self._qtest = QEMUQtestProtocol(self._qtest_path, server=True)
+
+    def _post_launch(self):
+        super(self, QEMUQtestMachine)._post_launch()
+        self._qtest.accept()
+
+    def _post_shutdown(self):
+        super(self, QEMUQtestMachine)._post_shutdown()
+        self._remove_if_exists(self._qtest_path)
+
+    def qtest(self, cmd):
+        '''Send a qtest command to guest'''
+        return self._qtest.cmd(cmd)
tests/qemu-iotests/iotests.py +4 -131

169 lines not on this page · raw message

Signature · 1 line
2.5.5
#4 lore raw

PATCH 4/6 scripts: set timeout when waiting for qemu monitor connection

In reply to Daniel P. Berrange

If QEMU fails to launch for some reason, the QEMUMonitorProtocol class accept() method will wait forever in a socket accept call. Set a timeout of 15 seconds so that we fail more gracefully instead of hanging the test script forever

---
 scripts/qmp/qmp.py | 1 +
 1 file changed, 1 insertion(+)
scripts/qmp/qmp.py +1 -0
index 70e927e..2d0d926 100644
@@ -140,6 +140,7 @@ class QEMUMonitorProtocol:
         @raise QMPConnectError if the greeting is not received
         @raise QMPCapabilitiesError if fails to negotiate capabilities
         """
+        self.__sock.settimeout(15)
         self.__sock, _ = self.__sock.accept()
         self.__sockfile = self.__sock.makefile()
         return self.__negotiate_capabilities()
Signature · 1 line
2.5.5
#5 lore raw

PATCH 5/6 scripts: ensure monitor socket has SO_REUSEADDR set

In reply to Daniel P. Berrange

If tests use a TCP based monitor socket, the connection will go into a TIMED_WAIT state when the test exits. This will randomly prevent the test from being re-run without a certain time period. Set the SO_REUSEADDR flag on the socket to ensure we can immediately re-run the tests

---
 scripts/qmp/qmp.py | 1 +
 1 file changed, 1 insertion(+)
scripts/qmp/qmp.py +1 -0
index 2d0d926..62d3651 100644
@@ -43,6 +43,7 @@ class QEMUMonitorProtocol:
         self._debug = debug
         self.__sock = self.__get_sock()
         if server:
+            self.__sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
             self.__sock.bind(self.__address)
             self.__sock.listen(1)
 
Signature · 1 line
2.5.5
#7 lore raw

PATCH 6/6 tests: introduce a framework for testing migration performance

In reply to Daniel P. Berrange

This introduces a moderately general purpose framework for testing performance of migration.

The initial guest workload is provided by the included 'stress' program, which is configured to spawn one thread per guest CPU and run a maximally memory intensive workload. It will loop over GB of memory, xor'ing each byte with data from a 4k array of random bytes. This ensures heavy read and write load across all of guest memory to stress the migration performance. While running the 'stress' program will record how long it takes to xor each GB of memory and print this data for later reporting.

The test engine will spawn a pair of QEMU processes, either on the same host, or with the target on a remote host via ssh, using the host kernel and a custom initrd built with 'stress' as the /init binary. Kernel command line args are set to ensure a fast kernel boot time (< 1 second) between launching QEMU and the stress program starting execution.

None the less, the test engine will initially wait N seconds for the guest workload to stablize, before starting the migration operation. When migration is running, the engine will use pause, post-copy, autoconverge, xbzrle compression and multithread compression features, as well as downtime & bandwidth tuning to encourage completion. If migration completes, the test engine will wait N seconds again for the guest workooad to stablize on the target host. If migration does not complete after a preset number of iterations, it will be aborted.

While the QEMU process is running on the source host, the test engine will sample the host CPU usage of QEMU as a whole, and each vCPU thread. While migration is running, it will record all the stats reported by 'query-migration'. Finally, it will capture the output of the stress program running in the guest.

All the data produced from a single test execution is recorded in a structured JSON file. A separate program is then able to create interactive charts using the "plotly" python + javascript libraries, showing the characteristics of the migration.

The data output provides visualization of the effect on guest vCPU workloads from the migration process, the corresponding vCPU utilization on the host, and the overall CPU hit from QEMU on the host. This is correlated from statistics from the migration process, such as downtime, vCPU throttling and iteration number.

While the tests can be run individually with arbitrary parameters, there is also a facility for producing batch reports for a number of pre-defined scenarios / comparisons, in order to be able to get standardized results across different hardware configurations (eg TCP vs RDMA, or comparing different VCPU counts / memory sizes, etc).

To use this, first you must build the initrd image

 $ make tests/migration/initrd-stress.img

To run a a one-shot test with all default parameters

 $ ./tests/migration/guestperf.py > result.json

This has many command line args for varying its behaviour. For example, to increase the RAM size and CPU count and bind it to specific host NUMA nodes

 $ ./tests/migration/guestperf.py \
       --mem 4 --cpus 2 \
       --src-mem-bind 0 --src-cpu-bind 0,1 \
       --dst-mem-bind 1 --dst-cpu-bind 2,3 \
       > result.json

Using mem + cpu binding is strongly recommended on NUMA machines, otherwise the guest performance results will vary wildly between runs of the test due to lucky/unlucky NUMA placement, making sensible data analysis impossible.

To make it run across separate hosts:

 $ ./tests/migration/guestperf.py \
       --dst-host somehostname > result.json

To request that post-copy is enabled, with switchover after 5 iterations

 $ ./tests/migration/guestperf.py \
       --post-copy --post-copy-iters 5 > result.json

Once a result.json file is created, a graph of the data can be generated, showing guest workload performance per thread and the migration iteration points:

 $ ./tests/migration/guestperf-plot.py --output result.html \
        --migration-iters --split-guest-cpu result.json

To further include host vCPU utilization and overall QEMU utilization

 $ ./tests/migration/guestperf-plot.py --output result.html \
        --migration-iters --split-guest-cpu \
	--qemu-cpu --vcpu-cpu result.json

NB, the 'guestperf-plot.py' command requires that you have the plotly python library installed. eg you must do

 $ pip install --user  plotly

Viewing the result.html file requires that you have the plotly.min.js file in the same directory as the HTML output. This js file is installed as part of the plotly python library, so can be found in

$HOME/.local/lib/python2.7/site-packages/plotly/offline/plotly.min.js

The guestperf-plot.py program can accept multiple json files to plot, enabling results from different configurations to be compared.

Finally, to run the entire standardized set of comparisons

  $ ./tests/migration/guestperf-batch.py \
       --dst-host somehost \
       --mem 4 --cpus 2 \
       --src-mem-bind 0 --src-cpu-bind 0,1 \
       --dst-mem-bind 1 --dst-cpu-bind 2,3
       --output tcp-somehost-4gb-2cpu

will store JSON files from all scenarios in the directory named tcp-somehost-4gb-2cpu

---
 configure                               |   2 +
 tests/Makefile                          |  12 +
 tests/migration/.gitignore              |   2 +
 tests/migration/guestperf-batch.py      |  26 ++
 tests/migration/guestperf-plot.py       |  26 ++
 tests/migration/guestperf.py            |  27 ++
 tests/migration/guestperf/__init__.py   |   0
 tests/migration/guestperf/comparison.py | 124 +++++++
 tests/migration/guestperf/engine.py     | 439 ++++++++++++++++++++++
 tests/migration/guestperf/hardware.py   |  62 ++++
 tests/migration/guestperf/plot.py       | 623 ++++++++++++++++++++++++++++++++
 tests/migration/guestperf/progress.py   | 117 ++++++
 tests/migration/guestperf/report.py     |  98 +++++
 tests/migration/guestperf/scenario.py   |  95 +++++
 tests/migration/guestperf/shell.py      | 255 +++++++++++++
 tests/migration/guestperf/timings.py    |  55 +++
 tests/migration/stress.c                | 367 +++++++++++++++++++
 17 files changed, 2330 insertions(+)
 create mode 100644 tests/migration/.gitignore
 create mode 100755 tests/migration/guestperf-batch.py
 create mode 100755 tests/migration/guestperf-plot.py
 create mode 100755 tests/migration/guestperf.py
 create mode 100644 tests/migration/guestperf/__init__.py
 create mode 100644 tests/migration/guestperf/comparison.py
 create mode 100644 tests/migration/guestperf/engine.py
 create mode 100644 tests/migration/guestperf/hardware.py
 create mode 100644 tests/migration/guestperf/plot.py
 create mode 100644 tests/migration/guestperf/progress.py
 create mode 100644 tests/migration/guestperf/report.py
 create mode 100644 tests/migration/guestperf/scenario.py
 create mode 100644 tests/migration/guestperf/shell.py
 create mode 100644 tests/migration/guestperf/timings.py
 create mode 100644 tests/migration/stress.c
configure +2 -0
index c37fc5f..43403d2 100755
@@ -3091,6 +3091,7 @@ else
       if test "$found" = "no"; then
         LIBS="$pthread_lib $LIBS"
       fi
+      PTHREAD_LIB="$pthread_lib"
       break
     fi
   done
@@ -5515,6 +5516,7 @@ echo "LDFLAGS=$LDFLAGS" >> $config_host_mak
 echo "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
 echo "LIBS+=$LIBS" >> $config_host_mak
 echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
+echo "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak
 echo "EXESUF=$EXESUF" >> $config_host_mak
 echo "DSOSUF=$DSOSUF" >> $config_host_mak
 echo "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
tests/Makefile +12 -0
index 9194f18..50b9d43 100644
@@ -589,6 +589,18 @@ tests/test-filter-redirector$(EXESUF): tests/test-filter-redirector.o $(qtest-ob
 tests/ivshmem-test$(EXESUF): tests/ivshmem-test.o contrib/ivshmem-server/ivshmem-server.o $(libqos-pc-obj-y)
 tests/vhost-user-bridge$(EXESUF): tests/vhost-user-bridge.o
 
+tests/migration/stress$(EXESUF): tests/migration/stress.o
+	$(call quiet-command, $(LINKPROG) -static -O3 $(PTHREAD_LIB) -o $@ $< ,"  LINK  $(TARGET_DIR)$@")
+
+INITRD_WORK_DIR=tests/migration/initrd
+
+tests/migration/initrd-stress.img: tests/migration/stress$(EXESUF)
+	mkdir -p $(INITRD_WORK_DIR)
+	cp $< $(INITRD_WORK_DIR)/init
+	(cd $(INITRD_WORK_DIR) && (find | cpio --quiet -o -H newc | gzip -9)) > $@
+	rm $(INITRD_WORK_DIR)/init
+	rmdir $(INITRD_WORK_DIR)
+
 ifeq ($(CONFIG_POSIX),y)
 LIBS += -lutil
 endif
tests/migration/.gitignore new file +2 -0
new file mode 100644
index 0000000..84f3755
@@ -0,0 +1,2 @@
+initrd-stress.img
+stress
tests/migration/guestperf-batch.py new file +26 -0
new file mode 100755
index 0000000..cb150ce
@@ -0,0 +1,26 @@
+#!/usr/bin/python
+#
+# Migration test batch comparison invokation
+#
+# Copyright (c) 2016 Red Hat, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, see <http://www.gnu.org/licenses/>.
+#
+
+import sys
+
+from guestperf.shell import BatchShell
+
+shell = BatchShell()
+sys.exit(shell.run(sys.argv[1:]))
tests/migration/guestperf-plot.py new file +26 -0
new file mode 100755
index 0000000..d70bb7a
@@ -0,0 +1,26 @@
+#!/usr/bin/python
+#
+# Migration test graph plotting command
+#
+# Copyright (c) 2016 Red Hat, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, see <http://www.gnu.org/licenses/>.
+#
+
+import sys
+
+from guestperf.shell import PlotShell
+
+shell = PlotShell()
+sys.exit(shell.run(sys.argv[1:]))
tests/migration/guestperf.py new file +27 -0
new file mode 100755
index 0000000..99b027e
@@ -0,0 +1,27 @@
+#!/usr/bin/python
+#
+# Migration test direct invokation command
+#
+# Copyright (c) 2016 Red Hat, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, see <http://www.gnu.org/licenses/>.
+#
+
+
+import sys
+
+from guestperf.shell import Shell
+
+shell = Shell()
+sys.exit(shell.run(sys.argv[1:]))
tests/migration/guestperf/__init__.py new file +0 -0
new file mode 100644
index 0000000..e69de29
tests/migration/guestperf/comparison.py new file +124 -0

124 lines not on this page · raw message

tests/migration/guestperf/engine.py new file +439 -0

439 lines not on this page · raw message

tests/migration/guestperf/hardware.py new file +62 -0

62 lines not on this page · raw message

tests/migration/guestperf/plot.py new file +623 -0

623 lines not on this page · raw message

tests/migration/guestperf/progress.py new file +117 -0

117 lines not on this page · raw message

tests/migration/guestperf/report.py new file +98 -0

98 lines not on this page · raw message

tests/migration/guestperf/scenario.py new file +95 -0

95 lines not on this page · raw message

tests/migration/guestperf/shell.py new file +255 -0

255 lines not on this page · raw message

tests/migration/guestperf/timings.py new file +55 -0

55 lines not on this page · raw message

tests/migration/stress.c new file +367 -0

367 lines not on this page · raw message

Signature · 1 line
2.5.5
#8 lore raw
In reply to Daniel P. Berrange
Quoted 41 lines · * Daniel P. Berrange ([email protected]) wrote:

This series of patches provides a framework for testing migration performance characteristics. The motivating factor for this is planning that is underway in OpenStack wrt making use of QEMU migration features such as compression, auto-converge and post-copy. The primary aim for OpenStack is to have Nova autonomously manage migration features & tunables to maximise chances that migration will complete. The problem faced is figuring out just which QEMU migration features are "best" suited to our needs. This means we want data on how well they are able to ensure completion of a migration, against the host resources used and the impact on the guest workload performance.

The test framework produced here takes a pathelogical guest workload (every CPU just burning 100% of time xor'ing every byte of guest memory with random data). This is quite a pessimistic test because most guest workloads are not giong to be this heavy on memory writes, and their data won't be uniformly random and so will be able to compress better than this test does.

With this worst case guest, I have produced a set of tests using UNIX socket, TCP localhost, TCP remote and RDMA remote socket transports, with both a 1 GB RAM + 1 CPU guest and a 8 GB RAM + 4 CPU guest.

The TCP/RDMA remote host tests were run over a 10-GiG-E network interface.

I have put the results online to view here:

https://berrange.fedorapeople.org/qemu-mig-test-2016-05-05/

The charts here are showing two core sets of data:

- The guest CPU performance. The left axis is showing the time in milliseconds required to xor 1 GB of memory. This is shown per-guest CPU and combined all CPUs.

- The host CPU utilization. The right axis is showing the overall QEMU process CPU utilization, and the per-VCPU utilization.

Note that the charts are interactive - you can turn on/off each plot line and zoom in by selecting regions on the chart.

Some interesting things that I have observed with this

Quoted 7 lines

- At the start of each iteration of migration there is a distinct drop in guest CPU performance as shown by a spike in the guest CPU time lines. Performance would drop from 200ms/GB to 400ms/GB. Presumably this is related to QEMU recalculating the dirty bitmap for the guest RAM. See the spikes in the green line in:

    https://berrange.fedorapeople.org/qemu-mig-test-2016-05-05/tcp-remote-1gb-1cpu/post-copy-bandwidth/post-copy-bw-1gbs.html

Yeh, that doesn't surprise me too much.

Quoted 10 lines

- For the larger sized guests, the auto-converge code has to throttle the guest to as much as 90% or more before it is able to meet the 500ms max downtime value

    https://berrange.fedorapeople.org/qemu-mig-test-2016-05-05/tcp-remote-1gb-1cpu/auto-converge-bandwidth/auto-converge-bw-1gbs.html

Even then I often saw tests aborting as they hit the max number of iterations I permitted (30 iters max)

    https://berrange.fedorapeople.org/qemu-mig-test-2016-05-05/tcp-remote-8gb-4cpu/auto-converge-bandwidth/auto-converge-bw-10gbs.html

It doesn't take much CPU to dirty memory, so you need an awful lot of throttling, and the throttling is non-discriminate so it throttles threads that are dirtying memory a lot as well as those that aren't.

Quoted 9 lines

- MT compression is actively harmful to chances of successful migration when the guest RAM is not compression friendly. My work load is worst case since it is splattering RAM with totally random bytes. The MT compression is dramatically increasing the time for each iteration as we bottleneck on CPU compression speed, leaving the network largely idle. This causes migration which would have completed without compression, to fail. It also burns huge amounts of host CPU time

     https://berrange.fedorapeople.org/qemu-mig-test-2016-05-05/tcp-remote-1gb-1cpu/compr-mt/compr-mt-threads-4.html

Yes; I think the hope is that this will work well with compression accelerator hardware. I look forward to the vendors of that hardware using your scripts to produce comparisons.

Quoted 21 lines

- XBZRLE compression did not have as much of a CPU peformance penalty on the host as MT comprssion, but also did not help migration to actually complete. Again this is largely due to the workload being the worst case scenario with random bytes. The downside is obviously the potentially significant memory overhead on the host due to the cache sizing

    https://berrange.fedorapeople.org/qemu-mig-test-2016-05-05/tcp-remote-1gb-1cpu/compr-xbzrle/compr-xbzrle-cache-50.html

- Post-copy, by its very nature, obviously ensured that the migraton would complete. While post-copy was running in pre-copy mode there was a somewhat chaotic small impact on guest CPU performance, causing performance to periodically oscillate between 400ms/GB and 800ms/GB. This is less than the impact at the start of each migration iteration which was 1000ms/GB in this test. There was also a massive penalty at time of switchover from pre to post copy, as to be expected. The migration completed in post-copy phase quite quickly though. For this workload, number of iterations in pre-copy mode before switching to post-copy did not have much impact. I expect a less extreme workload would have shown more interesting results wrt number of iterations of pre-copy:

Quoted 1 line
    https://berrange.fedorapeople.org/qemu-mig-test-2016-05-05/tcp-remote-8gb-4cpu/post-copy-iters.html

Hmm; I hadn't actually expected that much performance difference during the precopy phase (it used to in earlier postcopy versions but the later versions should have got simpler). The number of iterations wouldn't make that much difference for your workload - because you're changing all of memory then we're going to have to resend it; if you had a workload where some of the memory was mostly static and some was rapidly changing, then one or two passes to transfer the mostly static data would show a benefit.

Quoted 16 lines

Overall, if we're looking for a solution that can guarantee completion under the most extreme guest workload, then only post-copy & autoconverge appear upto the job.

The MT compression is seriously harmful to migration and has severe CPU overhead. The XBZRLE compression is moderatly harmful to migration and has potentilly severa memory overhead for large cache sizes to make it useful.

While auto-converge can ensure that guest migration completes, it has a pretty significantly long term impact on guest CPU performance to achieve this. ie the guest spends a long time in pre-copy mode with its CPUs very dramatically throttled down. The level of throttling required makes one wonder whether it is worth using, against simply pausing the guest workload. The latter has a hard blackout period, but over a quite short time frame if network speed is fast.

Quoted 7 lines

The post-copy code does have an impact on guest performance while in pre copy mode, vs a plain migration. It also has a fairly high spike when in post-copy mode, but this last for a pretty short time. As compared to auto-converge, it is able to ensure the migration completes in a finite time without having a prolonged impact on guest CPU performance. The penalty during the post-copy phase is on a par with the penalty impose by auto-converge when it has to throttle to 90%+.

One advantage of postcopy here is that it should be more selective on real workloads than auto-converge. If some threads have the data they need on the destination already, they can run without much performance impact. (Indeed that's actually threads, not even vCPUs, since the asynchronous page faults let the guest keep the vCPU busy even if one
thread is waiting).

Quoted 6 lines

Overall, in the context of a worst case guest workload, it appears that post-copy is the clear winning strategy ensuring completion of migration without imposing an long duration penalty on guest peformance. If the risk of failure from post-copy is unacceptable then auto-converge is a good fallback option, if the long duration guest CPU penalty can be accepted.

Excellent :-) And we have a GSoC student looking at recovery after network failure during postcopy - but as you see the actual postcopy phase is pretty short anyway, so the risk window is short.

Quoted 6 lines

The compression options are only worth using if the host has free CPU resources, and the guest RAM is believed to be compression friendly, as they steal significant CPU time away from guests in order to run compression, often with a negative impact on migration completion chances.

Quoted 9 lines

Looking at migration in general, even with a 10-GiG-E NIC and RDMA transport it is possible for a single guest to provide a workload that will saturate the network during migration & thus prevent completion. Based on this, there is little point in attempting to run migrations in parallel on the same host, unless multiple NICs are available, as parallel migrations would reduce the chances of either one ever completing. Better reliability & faster overall completion would likely be achieved by fully serializing migration operations per host.

Probably true; however:
a) 10Gb is a bit slow these days - you can get dual port 100Gb cards even so you'll never keep up with a CPU bus going flat out.

b) If your bandwidth is limited by single core CPU (e.g. encryption/ or just TCP speed) then two migrations might make sense if you still have spare cores and bandwidth.

c) If the destination of the two migrations are different hosts then hmm the discussion probably gets more complex :-)

Quoted 12 lines

There is clearly scope for more investigation here, in particular

- Produce some alternative guest workloads that try to present a more "average" scenario workload, instead of the worst-case. These would likely allow compression to have some positive impact.

- Try various combinations of strategies. For example, combining post-copy and auto-converge at the same time, or compression combined with either post-copy or auto-converge.

Quoted 5 lines

- Investigate block migration performance too, with NBD migration server.

- Investigate effect of dynamically changing max downtime value during migration, rather than using a fixed 500ms value.

Yes, and probably worth trying to figure out what's happening during the precopy phase of postcopy.

Dave

Quoted 42 lines

Daniel P. Berrange (6):
scripts: add __init__.py file to scripts/qmp/
scripts: add a 'debug' parameter to QEMUMonitorProtocol
scripts: refactor the VM class in iotests for reuse
scripts: set timeout when waiting for qemu monitor connection
scripts: ensure monitor socket has SO_REUSEADDR set
tests: introduce a framework for testing migration performance

 configure                               |   2 +
 scripts/qemu.py                         | 202 +++++++++++
 scripts/qmp/__init__.py                 |   0
 scripts/qmp/qmp.py                      |  15 +-
 scripts/qtest.py                        |  34 ++
 tests/Makefile                          |  12 +
 tests/migration/.gitignore              |   2 +
 tests/migration/guestperf-batch.py      |  26 ++
 tests/migration/guestperf-plot.py       |  26 ++
 tests/migration/guestperf.py            |  27 ++
 tests/migration/guestperf/__init__.py   |   0
 tests/migration/guestperf/comparison.py | 124 +++++++
 tests/migration/guestperf/engine.py     | 439 ++++++++++++++++++++++
 tests/migration/guestperf/hardware.py   |  62 ++++
 tests/migration/guestperf/plot.py       | 623 ++++++++++++++++++++++++++++++++
 tests/migration/guestperf/progress.py   | 117 ++++++
 tests/migration/guestperf/report.py     |  98 +++++
 tests/migration/guestperf/scenario.py   |  95 +++++
 tests/migration/guestperf/shell.py      | 255 +++++++++++++
 tests/migration/guestperf/timings.py    |  55 +++
 tests/migration/stress.c                | 367 +++++++++++++++++++
 tests/qemu-iotests/iotests.py           | 135 +------
 22 files changed, 2583 insertions(+), 133 deletions(-)
 create mode 100644 scripts/qemu.py
 create mode 100644 scripts/qmp/__init__.py
 create mode 100644 tests/migration/.gitignore
 create mode 100755 tests/migration/guestperf-batch.py
 create mode 100755 tests/migration/guestperf-plot.py
 create mode 100755 tests/migration/guestperf.py
 create mode 100644 tests/migration/guestperf/__init__.py
 create mode 100644 tests/migration/guestperf/comparison.py
 create mode 100644 tests/migration/guestperf/engine.py
Quoted 12 lines
 create mode 100644 tests/migration/guestperf/hardware.py
 create mode 100644 tests/migration/guestperf/plot.py
 create mode 100644 tests/migration/guestperf/progress.py
 create mode 100644 tests/migration/guestperf/report.py
 create mode 100644 tests/migration/guestperf/scenario.py
 create mode 100644 tests/migration/guestperf/shell.py
 create mode 100644 tests/migration/guestperf/timings.py
 create mode 100644 tests/migration/stress.c
Signature · 1 line
2.5.5

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#11 lore raw
In reply to Daniel P. Berrange
Quoted 11 lines

This series of patches provides a framework for testing migration performance characteristics. The motivating factor for this is planning that is underway in OpenStack wrt making use of QEMU migration features such as compression, auto-converge and post-copy. The primary aim for OpenStack is to have Nova autonomously manage migration features & tunables to maximise chances that migration will complete. The problem faced is figuring out just which QEMU migration features are "best" suited to our needs. This means we want data on how well they are able to ensure completion of a migration, against the host resources used and the impact on the guest workload performance.

Quoted 7 lines

The test framework produced here takes a pathelogical guest workload (every CPU just burning 100% of time xor'ing every byte of guest memory with random data). This is quite a pessimistic test because most guest workloads are not giong to be this heavy on memory writes, and their data won't be uniformly random and so will be able to compress better than this test does.

Wonderful test report!

Quoted 125 lines

With this worst case guest, I have produced a set of tests using UNIX socket, TCP localhost, TCP remote and RDMA remote socket transports, with both a 1 GB RAM + 1 CPU guest and a 8 GB RAM + 4 CPU guest.

The TCP/RDMA remote host tests were run over a 10-GiG-E network interface.

I have put the results online to view here:

https://berrange.fedorapeople.org/qemu-mig-test-2016-05-05/

The charts here are showing two core sets of data:

- The guest CPU performance. The left axis is showing the time in
milliseconds
required to xor 1 GB of memory. This is shown per-guest CPU and
combined all
CPUs.

- The host CPU utilization. The right axis is showing the overall QEMU process CPU utilization, and the per-VCPU utilization.

Note that the charts are interactive - you can turn on/off each plot line and zoom in by selecting regions on the chart.

Some interesting things that I have observed with this

- At the start of each iteration of migration there is a distinct drop in guest CPU performance as shown by a spike in the guest CPU time lines. Performance would drop from 200ms/GB to 400ms/GB. Presumably this is related to QEMU recalculating the dirty bitmap for the guest RAM. See the spikes in the green line in:

    https://berrange.fedorapeople.org/qemu-mig-test-2016-05-05/tcp-

remote-1gb-1cpu/post-copy-bandwidth/post-copy-bw-1gbs.html

- For the larger sized guests, the auto-converge code has to throttle the guest to as much as 90% or more before it is able to meet the 500ms max downtime value

    https://berrange.fedorapeople.org/qemu-mig-test-2016-05-05/tcp-

remote-1gb-1cpu/auto-converge-bandwidth/auto-converge-bw-1gbs.html

Even then I often saw tests aborting as they hit the max number of iterations I permitted (30 iters max)

    https://berrange.fedorapeople.org/qemu-mig-test-2016-05-05/tcp-

remote-8gb-4cpu/auto-converge-bandwidth/auto-converge-bw-10gbs.html

- MT compression is actively harmful to chances of successful migration
when
the guest RAM is not compression friendly. My work load is worst case
since
it is splattering RAM with totally random bytes. The MT compression is dramatically increasing the time for each iteration as we bottleneck on CPU compression speed, leaving the network largely idle. This causes migration which would have completed without compression, to fail. It also burns
huge
amounts of host CPU time

     https://berrange.fedorapeople.org/qemu-mig-test-2016-05-05/tcp-

remote-1gb-1cpu/compr-mt/compr-mt-threads-4.html

- XBZRLE compression did not have as much of a CPU peformance penalty on
the
host as MT comprssion, but also did not help migration to actually complete. Again this is largely due to the workload being the worst case scenario with random bytes. The downside is obviously the potentially significant
memory
overhead on the host due to the cache sizing

    https://berrange.fedorapeople.org/qemu-mig-test-2016-05-05/tcp-

remote-1gb-1cpu/compr-xbzrle/compr-xbzrle-cache-50.html

- Post-copy, by its very nature, obviously ensured that the migraton would complete. While post-copy was running in pre-copy mode there was a
somewhat
chaotic small impact on guest CPU performance, causing performance to periodically oscillate between 400ms/GB and 800ms/GB. This is less than the impact at the start of each migration iteration which was 1000ms/GB in this test. There was also a massive penalty at time of switchover from pre to post copy, as to be expected. The migration completed in post-copy phase quite quickly though. For this workload, number of iterations in pre-copy mode before switching to post-copy did not have much impact. I expect a less extreme workload would have shown more interesting results wrt number of iterations of pre-copy:

    https://berrange.fedorapeople.org/qemu-mig-test-2016-05-05/tcp-

remote-8gb-4cpu/post-copy-iters.html

Overall, if we're looking for a solution that can guarantee completion under the most extreme guest workload, then only post-copy & autoconverge appear upto the job.

The MT compression is seriously harmful to migration and has severe CPU overhead. The XBZRLE compression is moderatly harmful to migration and has potentilly severa memory overhead for large cache sizes to make it useful.

While auto-converge can ensure that guest migration completes, it has a pretty significantly long term impact on guest CPU performance to achieve this. ie the guest spends a long time in pre-copy mode with its CPUs very dramatically throttled down. The level of throttling required makes one wonder whether it is worth using, against simply pausing the guest workload. The latter has a hard blackout period, but over a quite short time frame if network speed is fast.

The post-copy code does have an impact on guest performance while in pre copy mode, vs a plain migration. It also has a fairly high spike when in post- copy mode, but this last for a pretty short time. As compared to auto- converge, it is able to ensure the migration completes in a finite time without having a prolonged impact on guest CPU performance. The penalty during the post-copy phase is on a par with the penalty impose by auto-converge when it has to throttle to 90%+.

Overall, in the context of a worst case guest workload, it appears that post- copy is the clear winning strategy ensuring completion of migration without imposing an long duration penalty on guest peformance. If the risk of failure from post-copy is unacceptable then auto-converge is a good fallback option, if the long duration guest CPU penalty can be accepted.

Quoted 5 lines

The compression options are only worth using if the host has free CPU resources, and the guest RAM is believed to be compression friendly, as they steal significant CPU time away from guests in order to run compression, often with a negative impact on migration completion chances.

MT compression should only be used when the network bandwidth is the bottle neck that effects live migration. Use other faster (de)compression algorithm can reduce the CPU overhead.

Liang

Quoted 79 lines

Looking at migration in general, even with a 10-GiG-E NIC and RDMA transport it is possible for a single guest to provide a workload that will saturate the network during migration & thus prevent completion. Based on this, there is little point in attempting to run migrations in parallel on the same host, unless multiple NICs are available, as parallel migrations would reduce the chances of either one ever completing. Better reliability & faster overall completion would likely be achieved by fully serializing migration operations per host.

There is clearly scope for more investigation here, in particular

- Produce some alternative guest workloads that try to present a more "average" scenario workload, instead of the worst-case. These would likely allow compression to have some positive impact.

- Try various combinations of strategies. For example, combining post-copy and auto-converge at the same time, or compression combined with either post-copy or auto-converge.

- Investigate block migration performance too, with NBD migration server.

- Investigate effect of dynamically changing max downtime value during migration, rather than using a fixed 500ms value.

Daniel P. Berrange (6):
scripts: add __init__.py file to scripts/qmp/
scripts: add a 'debug' parameter to QEMUMonitorProtocol
scripts: refactor the VM class in iotests for reuse
scripts: set timeout when waiting for qemu monitor connection
scripts: ensure monitor socket has SO_REUSEADDR set
tests: introduce a framework for testing migration performance

 configure                               |   2 +
 scripts/qemu.py                         | 202 +++++++++++
 scripts/qmp/__init__.py                 |   0
 scripts/qmp/qmp.py                      |  15 +-
 scripts/qtest.py                        |  34 ++
 tests/Makefile                          |  12 +
 tests/migration/.gitignore              |   2 +
 tests/migration/guestperf-batch.py      |  26 ++
 tests/migration/guestperf-plot.py       |  26 ++
 tests/migration/guestperf.py            |  27 ++
 tests/migration/guestperf/__init__.py   |   0
 tests/migration/guestperf/comparison.py | 124 +++++++
 tests/migration/guestperf/engine.py     | 439 ++++++++++++++++++++++
 tests/migration/guestperf/hardware.py   |  62 ++++
 tests/migration/guestperf/plot.py       | 623
++++++++++++++++++++++++++++++++
 tests/migration/guestperf/progress.py   | 117 ++++++
 tests/migration/guestperf/report.py     |  98 +++++
 tests/migration/guestperf/scenario.py   |  95 +++++
 tests/migration/guestperf/shell.py      | 255 +++++++++++++
 tests/migration/guestperf/timings.py    |  55 +++
 tests/migration/stress.c                | 367 +++++++++++++++++++
 tests/qemu-iotests/iotests.py           | 135 +------
 22 files changed, 2583 insertions(+), 133 deletions(-)  create mode 100644
scripts/qemu.py  create mode 100644 scripts/qmp/__init__.py  create mode
100644 tests/migration/.gitignore  create mode 100755
tests/migration/guestperf-batch.py
 create mode 100755 tests/migration/guestperf-plot.py  create mode 100755
tests/migration/guestperf.py  create mode 100644
tests/migration/guestperf/__init__.py
 create mode 100644 tests/migration/guestperf/comparison.py
 create mode 100644 tests/migration/guestperf/engine.py
 create mode 100644 tests/migration/guestperf/hardware.py
 create mode 100644 tests/migration/guestperf/plot.py  create mode 100644
tests/migration/guestperf/progress.py
 create mode 100644 tests/migration/guestperf/report.py
 create mode 100644 tests/migration/guestperf/scenario.py
 create mode 100644 tests/migration/guestperf/shell.py
 create mode 100644 tests/migration/guestperf/timings.py
 create mode 100644 tests/migration/stress.c

--
2.5.5

#12 lore raw
In reply to Daniel P. Berrange
Quoted 9 lines · Daniel P. Berrange

This series of patches provides a framework for testing migration performance characteristics. The motivating factor for this is planning that is underway in OpenStack wrt making use of QEMU migration features such as compression, auto-converge and post-copy. The primary aim for OpenStack is to have Nova autonomously manage migration features & tunables to maximise chances that migration will complete. The problem faced is figuring out just which QEMU migration features are "best" suited to our needs. This means we want data on how well they are able to ensure completion of a migration, against the host resources used and the impact on the guest workload performance.

This is nice.

Quoted 10 lines

The test framework produced here takes a pathelogical guest workload (every CPU just burning 100% of time xor'ing every byte of guest memory with random data). This is quite a pessimistic test because most guest workloads are not giong to be this heavy on memory writes, and their data won't be uniformly random and so will be able to compress better than this test does.

With this worst case guest, I have produced a set of tests using UNIX socket, TCP localhost, TCP remote and RDMA remote socket transports, with both a 1 GB RAM + 1 CPU guest and a 8 GB RAM + 4 CPU guest.

Are typical openstack guests just 8G or 4vcpu? Do you see larger guests? Interesting things only start when we have lots more RAM, and lots more vcpus to dirty that RAM.

Amit

#9 lore raw
In reply to Dr. David Alan Gilbert
Quoted 17 lines · Dr. David Alan Gilbert
Quoted 14 lines · * Daniel P. Berrange ([email protected]) wrote:

Some interesting things that I have observed with this

- Post-copy, by its very nature, obviously ensured that the migraton would complete. While post-copy was running in pre-copy mode there was a somewhat chaotic small impact on guest CPU performance, causing performance to periodically oscillate between 400ms/GB and 800ms/GB. This is less than the impact at the start of each migration iteration which was 1000ms/GB in this test. There was also a massive penalty at time of switchover from pre to post copy, as to be expected. The migration completed in post-copy phase quite quickly though. For this workload, number of iterations in pre-copy mode before switching to post-copy did not have much impact. I expect a less extreme workload would have shown more interesting results wrt number of iterations of pre-copy:

Quoted 1 line
    https://berrange.fedorapeople.org/qemu-mig-test-2016-05-05/tcp-remote-8gb-4cpu/post-copy-iters.html
Quoted 7 lines

Hmm; I hadn't actually expected that much performance difference during the precopy phase (it used to in earlier postcopy versions but the later versions should have got simpler). The number of iterations wouldn't make that much difference for your workload - because you're changing all of memory then we're going to have to resend it; if you had a workload where some of the memory was mostly static and some was rapidly changing, then one or two passes to transfer the mostly static data would show a benefit.

Ok, so I have repeated the tests with a standard kernel. I also measured the exact same settings except without post-copy active, and also see the exact same magnitude of jitter without post-copy. IOW, this is not the fault of post-copy, its a factor whenever migration is running. What is most interesting is that I see greater jitter in guest performance, the higher the overall network transfer bandwidth is. ie with migration throttled to 100mbs, the jitter is massively smaller than the jitter when it is allowed to use 10gbs. Also, I only see the jitter on my 4 vCPU guest, not the 1 vCPU guest.

The QEMU process is confined to only run on 4 pCPUs, so I believe the cause of this jitter is simply a result of the migration thread in QEMU stealing a little time from the vCPU threads.

IOW completely expected and there is no penalty of having post-copy enabled even if you never get beyond the pre-copy stage :-)

Regards,
Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
#10 lore raw
Quoted 26 lines · * Daniel P. Berrange ([email protected]) wrote:
Quoted 17 lines · Dr. David Alan Gilbert
Quoted 14 lines · * Daniel P. Berrange ([email protected]) wrote:

Some interesting things that I have observed with this

- Post-copy, by its very nature, obviously ensured that the migraton would complete. While post-copy was running in pre-copy mode there was a somewhat chaotic small impact on guest CPU performance, causing performance to periodically oscillate between 400ms/GB and 800ms/GB. This is less than the impact at the start of each migration iteration which was 1000ms/GB in this test. There was also a massive penalty at time of switchover from pre to post copy, as to be expected. The migration completed in post-copy phase quite quickly though. For this workload, number of iterations in pre-copy mode before switching to post-copy did not have much impact. I expect a less extreme workload would have shown more interesting results wrt number of iterations of pre-copy:

Quoted 1 line
    https://berrange.fedorapeople.org/qemu-mig-test-2016-05-05/tcp-remote-8gb-4cpu/post-copy-iters.html
Quoted 7 lines

Hmm; I hadn't actually expected that much performance difference during the precopy phase (it used to in earlier postcopy versions but the later versions should have got simpler). The number of iterations wouldn't make that much difference for your workload - because you're changing all of memory then we're going to have to resend it; if you had a workload where some of the memory was mostly static and some was rapidly changing, then one or two passes to transfer the mostly static data would show a benefit.

Quoted 4 lines

Ok, so I have repeated the tests with a standard kernel. I also measured the exact same settings except without post-copy active, and also see the exact same magnitude of jitter without post-copy. IOW, this is not the fault of post-copy, its a factor whenever migration is running.

OK, good.

Quoted 5 lines

What
is most interesting is that I see greater jitter in guest performance, the higher the overall network transfer bandwidth is. ie with migration throttled to 100mbs, the jitter is massively smaller than the jitter when it is allowed to use 10gbs.

That doesn't surprise me, for a few reasons; I think there are three main sources of overhead:
a) The syncing of the bitmap
b) Write faults after a sync when the guest redirties a page
c) The CPU overhead of shuffling pages down a socket and checking if they're zero etc

With a lower bandwidth connection (a) happens more rarely and (c) is lower. Also, since (a) happens more rarely, and you only fault a page once between sync's, (b) has a lower overhead.

Quoted 5 lines

Also, I only see the jitter on my 4 vCPU guest, not the 1 vCPU guest.

The QEMU process is confined to only run on 4 pCPUs, so I believe the cause of this jitter is simply a result of the migration thread in QEMU stealing a little time from the vCPU threads.

Oh yes, that's cruel - you need an extra pCPU for migration if you've got a fast network connection because (a) & (c) are quite expensive.

Quoted 2 lines

IOW completely expected and there is no penalty of having post-copy enabled even if you never get beyond the pre-copy stage :-)

Great.

Dave

Quoted 7 lines

Regards,
Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#6 lore raw

Re: [Qemu-devel] [PATCH v1 5/6] scripts: ensure monitor socket has SO_REUSEADDR set

In reply to Daniel P. Berrange
Quoted 5 lines · Daniel P. Berrange

If tests use a TCP based monitor socket, the connection will go into a TIMED_WAIT state when the test exits. This will randomly prevent the test from being re-run without a certain time period. Set the SO_REUSEADDR flag on the socket to ensure we can immediately re-run the tests

Missing sign-off.

Amit