From: Venky Shankar Date: Wed, 19 May 2021 05:27:12 +0000 (-0400) Subject: cephfs-top: switch to displaying average latencies and stdev X-Git-Tag: v16.2.11~317^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=03216ca3aad496a7482b01702235c8dc95907fcf;p=ceph.git cephfs-top: switch to displaying average latencies and stdev Do away with cumulative latencies -- those are not much useful. However, these types need to be maintained since `perf stats` command (via mgr/stats plugin) includes them. So, maintain a legacy metrics list which is ignored when choosing metrics to display. Signed-off-by: Venky Shankar (cherry picked from commit 60f33a8ca3055ec5ae5c8d67fd03f571bcec8892) --- diff --git a/src/tools/cephfs/top/cephfs-top b/src/tools/cephfs/top/cephfs-top index 113cc2c18db5..4fae3593bd75 100755 --- a/src/tools/cephfs/top/cephfs-top +++ b/src/tools/cephfs/top/cephfs-top @@ -7,6 +7,7 @@ import errno import json import signal import time +import math from collections import OrderedDict from datetime import datetime @@ -30,6 +31,7 @@ class MetricType(Enum): METRIC_TYPE_PERCENTAGE = 1 METRIC_TYPE_LATENCY = 2 METRIC_TYPE_SIZE = 3 + METRIC_TYPE_STDEV = 4 FS_TOP_PROG_STR = 'cephfs-top' @@ -53,6 +55,11 @@ MAIN_WINDOW_TOP_LINE_ITEMS_START = [ITEMS_PAD, FS_TOP_MAIN_WINDOW_COL_MNT_ROOT] MAIN_WINDOW_TOP_LINE_ITEMS_END = [FS_TOP_MAIN_WINDOW_COL_MNTPT_HOST_ADDR] +MAIN_WINDOW_TOP_LINE_METRICS_LEGACY = ["READ_LATENCY", + "WRITE_LATENCY", + "METADATA_LATENCY" + ] + # adjust this map according to stats version and maintain order # as emitted by mgr/stast MAIN_WINDOW_TOP_LINE_METRICS = OrderedDict([ @@ -66,6 +73,12 @@ MAIN_WINDOW_TOP_LINE_METRICS = OrderedDict([ ("OPENED_INODES", MetricType.METRIC_TYPE_NONE), ("READ_IO_SIZES", MetricType.METRIC_TYPE_SIZE), ("WRITE_IO_SIZES", MetricType.METRIC_TYPE_SIZE), + ("AVG_READ_LATENCY", MetricType.METRIC_TYPE_LATENCY), + ("STDEV_READ_LATENCY", MetricType.METRIC_TYPE_STDEV), + ("AVG_WRITE_LATENCY", MetricType.METRIC_TYPE_LATENCY), + ("STDEV_WRITE_LATENCY", MetricType.METRIC_TYPE_STDEV), + ("AVG_METADATA_LATENCY", MetricType.METRIC_TYPE_LATENCY), + ("STDEV_METADATA_LATENCY", MetricType.METRIC_TYPE_STDEV), ]) MGR_STATS_COUNTERS = list(MAIN_WINDOW_TOP_LINE_METRICS.keys()) @@ -98,6 +111,13 @@ def calc_lat(c): return round(c[0] + c[1] / 1000000000, 2) +def calc_stdev(c): + stdev = 0.0 + if c[1] > 1: + stdev = math.sqrt(c[0] / (c[1] - 1)) / 1000000 + return round(stdev, 2) + + # in MB def calc_size(c): return round(c[1] / (1024 * 1024), 2) @@ -228,6 +248,18 @@ class FSTop(object): return "rtio" if item == "WRITE_IO_SIZES": return "wtio" + if item == 'AVG_READ_LATENCY': + return 'rlatavg' + if item == 'STDEV_READ_LATENCY': + return 'rlatsd' + if item == 'AVG_WRITE_LATENCY': + return 'wlatavg' + if item == 'STDEV_WRITE_LATENCY': + return 'wlatsd' + if item == 'AVG_METADATA_LATENCY': + return 'mlatavg' + if item == 'STDEV_METADATA_LATENCY': + return 'mlatsd' else: # return empty string for none type return '' @@ -239,6 +271,8 @@ class FSTop(object): return "(s)" elif typ == MetricType.METRIC_TYPE_SIZE: return "(MB)" + elif typ == MetricType.METRIC_TYPE_STDEV: + return "(ms)" else: # return empty string for none type return '' @@ -283,6 +317,8 @@ class FSTop(object): xp += nlen for item, typ in MAIN_WINDOW_TOP_LINE_METRICS.items(): + if item in MAIN_WINDOW_TOP_LINE_METRICS_LEGACY: + continue it = f'{self.items(item)}{self.mtype(typ)}' heading.append(it) nlen = len(it) + len(ITEMS_PAD) @@ -334,6 +370,7 @@ class FSTop(object): def refresh_client(self, client_id, metrics, counters, client_meta, x_coord_map, y_coord): global last_time + size = 0 cur_time = time.time() duration = cur_time - last_time last_time = cur_time @@ -364,6 +401,9 @@ class FSTop(object): cidx = 0 client_id = x_coord_map[FS_TOP_MAIN_WINDOW_COL_CLIENT_ID] for item in counters: + if item in MAIN_WINDOW_TOP_LINE_METRICS_LEGACY: + cidx += 1 + continue coord = x_coord_map[item] hlen = coord[1] - len(ITEMS_PAD) hlen = min(hlen, remaining_hlen) @@ -379,6 +419,8 @@ class FSTop(object): self.mainw.addnstr(y_coord, coord[0], f'{calc_perc(m)}', hlen) elif typ == MetricType.METRIC_TYPE_LATENCY: self.mainw.addnstr(y_coord, coord[0], f'{calc_lat(m)}', hlen) + elif typ == MetricType.METRIC_TYPE_STDEV: + self.mainw.addnstr(y_coord, coord[0], f'{calc_stdev(m)}', hlen) elif typ == MetricType.METRIC_TYPE_SIZE: self.mainw.addnstr(y_coord, coord[0], f'{calc_size(m)}', hlen)