Skip to content

Commit 3e19d32

Browse files
author
Chris Harris
committed
Workload fixes for total_iodepth
Signed-off-by: CHris Harris(harriscr@uk.ibm.com)
1 parent 7892fa9 commit 3e19d32

File tree

1 file changed

+55
-18
lines changed

1 file changed

+55
-18
lines changed

benchmark/librbdfio.py

Lines changed: 55 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import settings
1010
import monitoring
1111

12-
from typing import Optional
1312
from .benchmark import Benchmark
1413

1514
logger = logging.getLogger("cbt")
@@ -33,7 +32,6 @@ def __init__(self, archive_dir, cluster, config):
3332
# would be nice to have them as a separate class -- future PR
3433
self.time_based = bool(config.get('time_based', False))
3534
self.ramp = config.get('ramp', None)
36-
self.iodepth = config.get('iodepth', 16)
3735
self.numjobs = config.get('numjobs', 1)
3836
self.end_fsync = config.get('end_fsync', 0)
3937
self.mode = config.get('mode', 'write')
@@ -52,12 +50,11 @@ def __init__(self, archive_dir, cluster, config):
5250
self.fio_out_format = config.get('fio_out_format', 'json,normal')
5351
self.data_pool = None
5452

55-
self._ioddepth_per_volume: dict[int, int] = {}
56-
total_iodepth: Optional[str] = config.get("total_iodepth", None)
57-
if total_iodepth is not None:
58-
self._ioddepth_per_volume = self._calculate_iodepth_per_volume(
59-
int(self.volumes_per_client), int(total_iodepth)
60-
)
53+
iodepth_key: str = self._get_iodepth_key(config.keys()) # type: ignore[arg-type]
54+
self.iodepth: str = config.get(iodepth_key, "16")
55+
self._iodepth_per_volume: dict[int, int] = self._calculate_iodepth_per_volume(
56+
self.volumes_per_client, int(self.iodepth), iodepth_key
57+
)
6158

6259
# use_existing_volumes needs to be true to set the pool and rbd names
6360
self.use_existing_volumes = bool(config.get('use_existing_volumes', False))
@@ -172,18 +169,23 @@ def run_workloads(self):
172169
enable_monitor = bool(test['monitor'])
173170
# TODO: simplify this loop to have a single iterator for general queu depth
174171
for job in test['numjobs']:
175-
for iod in test['iodepth']:
172+
iodepth_key: str = self._get_iodepth_key(test.keys()) # type: ignore[arg-type]
173+
for iodepth_value in test[iodepth_key]:
174+
self._iodepth_per_volume = self._calculate_iodepth_per_volume(
175+
int(self.volumes_per_client), int(iodepth_value), iodepth_key
176+
)
176177
self.mode = test['mode']
177178
if 'op_size' in test:
178179
self.op_size = test['op_size']
179180
self.mode = test['mode']
180181
self.numjobs = job
181-
self.iodepth = iod
182+
self.iodepth = iodepth_value
182183
self.run_dir = ( f'{self.base_run_dir}/{self.mode}_{int(self.op_size)}/'
183184
f'iodepth-{int(self.iodepth):03d}/numjobs-{int(self.numjobs):03d}' )
184185
common.make_remote_dir(self.run_dir)
185186

186-
for i in range(self.volumes_per_client):
187+
number_of_volumes: int = len(self._iodepth_per_volume.keys())
188+
for i in range(number_of_volumes):
187189
fio_cmd = self.mkfiocmd(i)
188190
p = common.pdsh(settings.getnodes('clients'), fio_cmd)
189191
ps.append(p)
@@ -235,7 +237,8 @@ def run(self):
235237
monitoring.start(self.run_dir)
236238
logger.info('Running rbd fio %s test.', self.mode)
237239
ps = []
238-
for i in range(self.volumes_per_client):
240+
number_of_volumes: int = len(self._iodepth_per_volume.keys())
241+
for i in range(number_of_volumes):
239242
fio_cmd = self.mkfiocmd(i)
240243
p = common.pdsh(settings.getnodes('clients'), fio_cmd)
241244
ps.append(p)
@@ -284,10 +287,8 @@ def mkfiocmd(self, volnum: int) -> str:
284287
fio_cmd += ' --direct=1'
285288
fio_cmd += ' --bs=%dB' % self.op_size
286289

287-
iodepth: str = f"{self.iodepth}"
288-
if self._ioddepth_per_volume != {}:
289-
iodepth = f"{self._ioddepth_per_volume[volnum]}"
290-
290+
iodepth: str = f"{self._iodepth_per_volume[volnum]}"
291+
291292
fio_cmd += ' --iodepth=%s' % iodepth
292293
fio_cmd += ' --end_fsync=%d' % self.end_fsync
293294
# if self.vol_size:
@@ -415,7 +416,33 @@ def analyze(self, out_dir):
415416
logger.info('Convert results to json format.')
416417
self.parse(out_dir)
417418

418-
def _calculate_iodepth_per_volume(self, number_of_volumes: int, total_desired_iodepth: int) -> dict[int, int]:
419+
def _get_iodepth_key(self, configuration_keys: list[str]) -> str:
420+
"""
421+
Get the string that represents the key to use when reading the iodepth
422+
values from the configuration. This will be 'total_iodepth' if it is
423+
present, otherwise iodepth
424+
"""
425+
iodepth_key: str = "iodepth"
426+
if "total_iodepth" in configuration_keys:
427+
iodepth_key = "total_iodepth"
428+
429+
return iodepth_key
430+
431+
def _calculate_iodepth_per_volume(self, number_of_volumes: int, iodepth: int, iodepth_key: str) -> dict[int, int]:
432+
"""
433+
Calculate the desired iodepth per volume for a single benchmark run.
434+
If total_iodepth is to be used calculate what the iodepth per volume
435+
should be and return that, otherwise return the iodepth value for each
436+
volume
437+
"""
438+
if iodepth_key == "total_iodepth":
439+
return self._calculate_iodepth_per_volume_from_total_iodepth(number_of_volumes, iodepth)
440+
else:
441+
return self._set_iodepth_for_every_volume(number_of_volumes, iodepth)
442+
443+
def _calculate_iodepth_per_volume_from_total_iodepth(
444+
self, number_of_volumes: int, total_desired_iodepth: int
445+
) -> dict[int, int]:
419446
"""
420447
Given the total desired iodepth and the number of volumes from the
421448
configuration yaml file, calculate the iodepth for each volume
@@ -436,7 +463,6 @@ def _calculate_iodepth_per_volume(self, number_of_volumes: int, total_desired_io
436463
"Number of volumes per client will be reduced from %s to %s", number_of_volumes, total_desired_iodepth
437464
)
438465
number_of_volumes = total_desired_iodepth
439-
self.volumes_per_client = number_of_volumes
440466

441467
iodepth_per_volume: int = total_desired_iodepth // number_of_volumes
442468
remainder: int = total_desired_iodepth % number_of_volumes
@@ -451,5 +477,16 @@ def _calculate_iodepth_per_volume(self, number_of_volumes: int, total_desired_io
451477

452478
return queue_depths
453479

480+
def _set_iodepth_for_every_volume(self, number_of_volumes: int, iodepth: int) -> dict[int, int]:
481+
"""
482+
Given an iodepth value and the number of volumes return a dictionary
483+
that contains the desired iodepth value for each volume
484+
"""
485+
queue_depths: dict[int, int] = {}
486+
for volume_id in range(number_of_volumes):
487+
queue_depths[volume_id] = iodepth
488+
489+
return queue_depths
490+
454491
def __str__(self):
455492
return "%s\n%s\n%s" % (self.run_dir, self.out_dir, super(LibrbdFio, self).__str__())

0 commit comments

Comments
 (0)