Francesco Romani has uploaded a new change for review. Change subject: virt: sampling: consolidate disk statistics ......................................................................
virt: sampling: consolidate disk statistics We used to have two different sampling, and thus two libvirt calls for sampling, for disk. One sampling gathers basic disk data and R/W rate; the other one gathers the disk latency. We can read all the needed information in one go, thus saving one not cheap libvirt call without losing any information. This patch does that. Change-Id: I0dabd079f81270c7099c74469a18f8b23c97cc8c Signed-off-by: Francesco Romani <[email protected]> --- M lib/vdsm/config.py.in M vdsm/virt/vm.py 2 files changed, 17 insertions(+), 42 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/53/29953/1 diff --git a/lib/vdsm/config.py.in b/lib/vdsm/config.py.in index 52e0cd9..9f67c25 100644 --- a/lib/vdsm/config.py.in +++ b/lib/vdsm/config.py.in @@ -165,10 +165,6 @@ ('vm_sample_disk_window', '2', None), - ('vm_sample_disk_latency_interval', '60', None), - - ('vm_sample_disk_latency_window', '2', None), - ('vm_sample_net_interval', '15', None), ('vm_sample_net_window', '2', None), diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py index 1082d1c..667b9ca 100644 --- a/vdsm/virt/vm.py +++ b/vdsm/virt/vm.py @@ -205,11 +205,6 @@ self._sampleDisk, config.getint('vars', 'vm_sample_disk_interval'), config.getint('vars', 'vm_sample_disk_window'))) - self.sampleDiskLatency = ( - AdvancedStatsFunction( - self._sampleDiskLatency, - config.getint('vars', 'vm_sample_disk_latency_interval'), - config.getint('vars', 'vm_sample_disk_latency_window'))) self.sampleNet = ( AdvancedStatsFunction( self._sampleNet, @@ -238,8 +233,8 @@ self.addStatsFunction( self.highWrite, self.updateVolumes, self.sampleCpu, - self.sampleDisk, self.sampleDiskLatency, self.sampleNet, - self.sampleBalloon, self.sampleVmJobs, self.sampleVcpuPinning, + self.sampleDisk, self.sampleNet, self.sampleBalloon, + self.sampleVmJobs, self.sampleVcpuPinning, self.sampleCpuTune) def _highWrite(self): @@ -265,25 +260,16 @@ # Avoid queries from storage during recovery process return - diskSamples = {} - for vmDrive in self._vm.getDiskDevices(): - diskSamples[vmDrive.name] = self._vm._dom.blockStats(vmDrive.name) - - return diskSamples - - def _sampleDiskLatency(self): - if not self._vm.isDisksStatsCollectionEnabled(): - # Avoid queries from storage during recovery process - return # {'wr_total_times': 0L, 'rd_operations': 9638L, # 'flush_total_times': 0L,'rd_total_times': 7622718001L, # 'rd_bytes': 85172430L, 'flush_operations': 0L, # 'wr_operations': 0L, 'wr_bytes': 0L} - diskLatency = {} + diskSamples = {} for vmDrive in self._vm.getDiskDevices(): - diskLatency[vmDrive.name] = self._vm._dom.blockStatsFlags( + diskSamples[vmDrive.name] = self._vm._dom.blockStatsFlags( vmDrive.name, flags=libvirt.VIR_TYPED_PARAM_STRING_OKAY) - return diskLatency + + return diskSamples def _sampleNet(self): netSamples = {} @@ -517,6 +503,13 @@ # will be None if sampled during recovery dStats.update(self._calcDiskRate(vmDrive, sInfo, eInfo, sampleInterval)) + dLatency = self._calcDiskLatency(vmDrive, sInfo, eInfo, + sampleInterval) + else: + dLatency = {'readLatency': '0', + 'writeLatency': '0', + 'flushLatency': '0'} + dStats.update(dLantency) except (AttributeError, KeyError, TypeError, ZeroDivisionError): self._log.exception("Disk %s stats not available", dName) @@ -526,29 +519,16 @@ try: return { 'readRate': ( - (eInfo[vmDrive.name][1] - sInfo[vmDrive.name][1]) + (eInfo[vmDrive.name]['rd_bytes'] - + sInfo[vmDrive.name]['rd_bytes']) / sampleInterval), 'writeRate': ( - (eInfo[vmDrive.name][3] - sInfo[vmDrive.name][3]) + (eInfo[vmDrive.name]['wr_bytes'] - + sInfo[vmDrive.name]['wr_bytes']) / sampleInterval) } except (AttributeError, KeyError, TypeError, ZeroDivisionError): self._log.exception("Disk %s stats not available", vmDrive.name) return { 'readRate': '0', 'writeRate': '0' } - - def _getDiskLatency(self, stats): - sInfo, eInfo, sampleInterval = self.sampleDiskLatency.getStats() - - for vmDrive in self._vm.getDiskDevices(): - if sInfo is not None: - dLatency = self._calcDiskLatency(vmDrive, sInfo, eInfo, - sampleInterval) - else: - # will be None if sampled during recovery - dLatency = {'readLatency': '0', - 'writeLatency': '0', - 'flushLatency': '0'} - - stats[dName].update(dLatency) def _calcDiskLatency(self, vmDrive, sInfo, eInfo, sampleInterval): try: @@ -604,7 +584,6 @@ self._getCpuStats(stats) self._getNetworkStats(stats) self._getDiskStats(stats) - self._getDiskLatency(stats) self._getBalloonStats(stats) self._getVmJobs(stats) -- To view, visit http://gerrit.ovirt.org/29953 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0dabd079f81270c7099c74469a18f8b23c97cc8c Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Francesco Romani <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
