Change in vdsm[master]: multipath: Replace timing code with utils.stopwatch

nsoffer at redhat.com nsoffer at redhat.com
Thu Jun 18 20:56:18 UTC 2015


Nir Soffer has uploaded a new change for review.

Change subject: multipath: Replace timing code with utils.stopwatch
......................................................................

multipath: Replace timing code with utils.stopwatch

The old timing code was longer then the code it measured, and it was
issuing 2 syscalls even if debug log was not enabled. Using the
stopwatch contextmanager, we need only one line of code, and we measure
the time only if we need to log it.

Change-Id: Ic9ae9c4f7b9e10ef07f1c9a8e8bce9aaf042d9af
Signed-off-by: Nir Soffer <nsoffer at redhat.com>
---
M vdsm/storage/multipath.py
1 file changed, 8 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/66/42566/1

diff --git a/vdsm/storage/multipath.py b/vdsm/storage/multipath.py
index 170df08..6d094e0 100644
--- a/vdsm/storage/multipath.py
+++ b/vdsm/storage/multipath.py
@@ -131,16 +131,14 @@
     """
     log.debug("Resizing map %r", name)
     cmd = [_MULTIPATHD.cmd, "resize", "map", name]
-    start = utils.monotonic_time()
-    rc, out, err = utils.execCmd(cmd, raw=True, execCmdLogger=log)
-    # multipathd reports some errors using non-zero exit code and stderr (need
-    # to be root), but the command may return 0, and the result is reported
-    # using stdout.
-    if rc != 0 or out != "ok\n":
-        raise Error("Resizing map %r failed: out=%r err=%r"
-                    % (name, out, err))
-    elapsed = utils.monotonic_time() - start
-    log.debug("Resized map %r in %.2f seconds", name, elapsed)
+    with utils.stopwatch("Resized map %r" % name):
+        rc, out, err = utils.execCmd(cmd, raw=True, execCmdLogger=log)
+        # multipathd reports some errors using non-zero exit code and stderr (need
+        # to be root), but the command may return 0, and the result is reported
+        # using stdout.
+        if rc != 0 or out != "ok\n":
+            raise Error("Resizing map %r failed: out=%r err=%r"
+                        % (name, out, err))
 
 
 def deduceType(a, b):


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic9ae9c4f7b9e10ef07f1c9a8e8bce9aaf042d9af
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer at redhat.com>


More information about the vdsm-patches mailing list