Bug 1013730 - Have mach ignore broken disk io stats; r=gps a=NPOTB
authorMike Shal <mshal@mozilla.com>
Wed, 01 Oct 2014 13:14:58 -0400
changeset 225990 daabf4d8995f
parent 225989 6ab542eb236d
child 225991 8a6160e2ef98
push id4099
push usermshal@mozilla.com
push date2014-11-07 15:57 +0000
treeherdermozilla-beta@dc18ad2b4816 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps, NPOTB
bugs1013730
milestone34.0
Bug 1013730 - Have mach ignore broken disk io stats; r=gps a=NPOTB This works around the "RuntimeError: couldn't find any physical disk" issue on Windows when using 'diskperf -n'
testing/mozbase/mozsystemmonitor/mozsystemmonitor/resourcemonitor.py
--- a/testing/mozbase/mozsystemmonitor/mozsystemmonitor/resourcemonitor.py
+++ b/testing/mozbase/mozsystemmonitor/mozsystemmonitor/resourcemonitor.py
@@ -14,43 +14,51 @@ except Exception:
 
 from collections import (
     OrderedDict,
     namedtuple,
 )
 
 from contextlib import contextmanager
 
+def get_disk_io_counters():
+    try:
+        io_counters = psutil.disk_io_counters()
+    except RuntimeError:
+        io_counters = []
+
+    return io_counters
+
 
 def _collect(pipe, poll_interval):
     """Collects system metrics.
 
     This is the main function for the background process. It collects
     data then forwards it on a pipe until told to stop.
     """
 
     data = []
 
     # Establish initial values.
 
     # We should ideally use a monotonic clock. However, Python 2.7 doesn't
     # make a monotonic clock available on all platforms. Python 3.3 does!
     last_time = time.time()
-    io_last = psutil.disk_io_counters()
+    io_last = get_disk_io_counters()
     cpu_last = psutil.cpu_times(True)
     swap_last = psutil.swap_memory()
     psutil.cpu_percent(None, True)
 
     sin_index = swap_last._fields.index('sin')
     sout_index = swap_last._fields.index('sout')
 
     sleep_interval = poll_interval
 
     while not pipe.poll(sleep_interval):
-        io = psutil.disk_io_counters()
+        io = get_disk_io_counters()
         cpu_times = psutil.cpu_times(True)
         cpu_percent = psutil.cpu_percent(None, True)
         virt_mem = psutil.virtual_memory()
         swap_mem = psutil.swap_memory()
         measured_end_time = time.time()
 
         # TODO Does this wrap? At 32 bits? At 64 bits?
         # TODO Consider patching "delta" API to upstream.
@@ -171,17 +179,17 @@ class SystemResourceMonitor(object):
         self._running = False
         self._stopped = False
 
         if psutil is None:
             return
 
         cpu_percent = psutil.cpu_percent(0.0, True)
         cpu_times = psutil.cpu_times(False)
-        io = psutil.disk_io_counters()
+        io = get_disk_io_counters()
         virt = psutil.virtual_memory()
         swap = psutil.swap_memory()
 
         self._cpu_cores = len(cpu_percent)
         self._cpu_times_type = type(cpu_times)
         self._cpu_times_len = len(cpu_times)
         self._io_type = type(io)
         self._io_len = len(io)