From db65d583597974724571376aa521269f3d152c42 Mon Sep 17 00:00:00 2001 From: Maciej Wawryk Date: Fri, 10 Jan 2020 13:40:16 +0100 Subject: [PATCH] Add pcm measurement to nvmf tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PCM - Processor Counter Monitor is an application to monitor performance and energy metrics of Intel® Core™, Xeon®, Atom™ and Xeon Phi™ processors. Using this measure tool will help us to capture memory bandwidth consumed on Intel processors. Signed-off-by: Maciej Wawryk Change-Id: Ie580d2aad6ddd98c5256df65f65e478dd78317e5 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/541 Tested-by: SPDK CI Jenkins Reviewed-by: Karol Latecki Reviewed-by: Tomasz Zawadzki Reviewed-by: Paul Luse Reviewed-by: Ben Walker --- scripts/perf/nvmf/README.md | 15 +++++++++++++ scripts/perf/nvmf/run_nvmf.py | 40 ++++++++++++++++++++++++++++++----- 2 files changed, 50 insertions(+), 5 deletions(-) diff --git a/scripts/perf/nvmf/README.md b/scripts/perf/nvmf/README.md index 7199efbb00e..fa1975cf0a1 100644 --- a/scripts/perf/nvmf/README.md +++ b/scripts/perf/nvmf/README.md @@ -86,3 +86,18 @@ as a runtime environment parameter. # Test Results When the test completes, you will find a csv file (nvmf_results.csv) containing the results in the target node directory /tmp/results. + +#Processor Counter Monitor (PCM) +PCM Tools provides a number of command-line utilities for real-time monitoring. +Before using PCM Tools in nvmf perf scripts it needs to be installed on Target machine. +PCM source and instructions are available on https://github.com/opcm/pcm. +To enable PCM in perf test you need to add Target setting in config.json file: +``` +"pcm_settings": ["pcm_directory", "measure_cpu", "measure_memory", delay_time, measure_interval, sample_count] +``` +example: +``` +"pcm_settings": ["/tmp/pcm", true, true, 10, 1, 30] +``` +Example above will run PCM measure for cpu and memory, with start delay 10s, sample every 1 second, +and 30 samples for cpu measure. PCM memory do not support sample count. diff --git a/scripts/perf/nvmf/run_nvmf.py b/scripts/perf/nvmf/run_nvmf.py index 5f216e987ec..4870419bb93 100755 --- a/scripts/perf/nvmf/run_nvmf.py +++ b/scripts/perf/nvmf/run_nvmf.py @@ -35,14 +35,20 @@ def log_print(self, msg): class Target(Server): def __init__(self, name, username, password, mode, nic_ips, transport="rdma", - use_null_block=False, sar_settings=None): + use_null_block=False, sar_settings=None, pcm_settings=None): super(Target, self).__init__(name, username, password, mode, nic_ips, transport) self.null_block = bool(use_null_block) self.enable_sar = False + self.enable_pcm_memory = False + self.enable_pcm = False + if sar_settings: self.enable_sar, self.sar_delay, self.sar_interval, self.sar_count = sar_settings + if pcm_settings: + self.pcm_dir, self.enable_pcm, self.enable_pcm_memory, self.pcm_delay, self.pcm_interval, self.pcm_count = pcm_settings + self.script_dir = os.path.dirname(os.path.abspath(sys.argv[0])) self.spdk_dir = os.path.abspath(os.path.join(self.script_dir, "../../../")) @@ -176,6 +182,18 @@ def measure_sar(self, results_dir, sar_file_name): self.log_print(line) fh.write(out) + def measure_pcm_memory(self, results_dir, pcm_file_name): + time.sleep(self.pcm_delay) + pcm_memory = subprocess.Popen("%s/pcm-memory.x %s -csv=%s/%s" % (self.pcm_dir, self.pcm_interval, + results_dir, pcm_file_name), shell=True) + time.sleep(self.pcm_count) + pcm_memory.kill() + + def measure_pcm(self, results_dir, pcm_file_name): + time.sleep(self.pcm_delay) + subprocess.run("%s/pcm.x %s -i=%s -csv=%s/%s" % (self.pcm_dir, self.pcm_interval, self.pcm_count, + results_dir, pcm_file_name), shell=True, check=True) + class Initiator(Server): def __init__(self, name, username, password, mode, nic_ips, ip, transport="rdma", @@ -327,11 +345,11 @@ def run_fio(self, fio_config_file, run_num=None): class KernelTarget(Target): def __init__(self, name, username, password, mode, nic_ips, transport="rdma", - use_null_block=False, sar_settings=None, + use_null_block=False, sar_settings=None, pcm_settings=None, nvmet_bin="nvmetcli", **kwargs): super(KernelTarget, self).__init__(name, username, password, mode, nic_ips, transport, - use_null_block, sar_settings) + use_null_block, sar_settings, pcm_settings) self.nvmet_bin = nvmet_bin def __del__(self): @@ -455,11 +473,11 @@ def tgt_start(self): class SPDKTarget(Target): def __init__(self, name, username, password, mode, nic_ips, transport="rdma", - use_null_block=False, sar_settings=None, + use_null_block=False, sar_settings=None, pcm_settings=None, num_shared_buffers=4096, num_cores=1, **kwargs): super(SPDKTarget, self).__init__(name, username, password, mode, nic_ips, transport, - use_null_block, sar_settings) + use_null_block, sar_settings, pcm_settings) self.num_cores = num_cores self.num_shared_buffers = num_shared_buffers @@ -743,6 +761,18 @@ def gen_fio_filename_conf(self, remote_subsystem_list): t = threading.Thread(target=target_obj.measure_sar, args=(target_results_dir, sar_file_name)) threads.append(t) + if target_obj.enable_pcm: + pcm_file_name = "_".join(["pcm_cpu", str(block_size), str(rw), str(io_depth)]) + pcm_file_name = ".".join([pcm_file_name, "csv"]) + t = threading.Thread(target=target_obj.measure_pcm, args=(target_results_dir, pcm_file_name,)) + threads.append(t) + + if target_obj.enable_pcm_memory: + pcm_file_name = "_".join(["pcm_memory", str(block_size), str(rw), str(io_depth)]) + pcm_file_name = ".".join([pcm_file_name, "csv"]) + t = threading.Thread(target=target_obj.measure_pcm_memory, args=(target_results_dir, pcm_file_name,)) + threads.append(t) + for t in threads: t.start() for t in threads: