Skip to content

Commit

Permalink
Add pcm measurement to nvmf tests
Browse files Browse the repository at this point in the history
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 <maciejx.wawryk@intel.com>
Change-Id: Ie580d2aad6ddd98c5256df65f65e478dd78317e5
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/541
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
  • Loading branch information
Maciej Wawryk authored and tomzawadzki committed Feb 11, 2020
1 parent e5bf4f0 commit db65d58
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 5 deletions.
15 changes: 15 additions & 0 deletions scripts/perf/nvmf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
40 changes: 35 additions & 5 deletions scripts/perf/nvmf/run_nvmf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, "../../../"))

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit db65d58

Please sign in to comment.