diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
commit | 19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch) | |
tree | 42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/spdk/scripts/histogram.py | |
parent | Initial commit. (diff) | |
download | ceph-upstream.tar.xz ceph-upstream.zip |
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/spdk/scripts/histogram.py')
-rwxr-xr-x | src/spdk/scripts/histogram.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/spdk/scripts/histogram.py b/src/spdk/scripts/histogram.py new file mode 100755 index 000000000..9d0b10fc0 --- /dev/null +++ b/src/spdk/scripts/histogram.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python3 + +import sys +import json +import base64 +import struct + +buf = sys.stdin.readlines() +json = json.loads(" ".join(buf)) +histogram = base64.b64decode(json["histogram"]) +bucket_shift = json["bucket_shift"] +tsc_rate = json["tsc_rate"] + +print("Latency histogram") +print("==============================================================================") +print(" Range in us Cumulative IO count") + +so_far = 0 +bucket = 0 +total = 1 + +for i in range(0, 64 - bucket_shift): + for j in range(0, (1 << bucket_shift)): + index = (((i << bucket_shift) + j) * 8) + total += int.from_bytes(histogram[index:index + 8], 'little') + +for i in range(0, 64 - bucket_shift): + for j in range(0, (1 << bucket_shift)): + index = (((i << bucket_shift) + j)*8) + count = int.from_bytes(histogram[index:index + 8], 'little') + so_far += count + last_bucket = bucket + + if i > 0: + bucket = (1 << (i + bucket_shift - 1)) + bucket += ((j+1) << (i - 1)) + else: + bucket = j+1 + + start = last_bucket * 1000 * 1000 / tsc_rate + end = bucket * 1000 * 1000 / tsc_rate + so_far_pct = so_far * 100.0 / total + if count > 0: + print("%9.3f - %9.3f: %9.4f%% (%9u)" % (start, end, so_far_pct, count)) |