@@ -52,12 +52,10 @@ def __init__(self, archive_dir, cluster, config):
5252 self .fio_out_format = config .get ('fio_out_format' , 'json,normal' )
5353 self .data_pool = None
5454
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- )
55+ iodepth_key : str = self ._get_iodepth_key (config .keys ()) # type: ignore[arg-type]
56+ self ._iodepth_per_volume : dict [int , int ] = self ._calculate_iodepth_per_volume (
57+ self .volumes_per_client , config [iodepth_key ], iodepth_key
58+ )
6159
6260 # use_existing_volumes needs to be true to set the pool and rbd names
6361 self .use_existing_volumes = bool (config .get ('use_existing_volumes' , False ))
@@ -172,7 +170,11 @@ def run_workloads(self):
172170 enable_monitor = bool (test ['monitor' ])
173171 # TODO: simplify this loop to have a single iterator for general queu depth
174172 for job in test ['numjobs' ]:
175- for iod in test ['iodepth' ]:
173+ iodepth_key : str = self ._get_iodepth_key (test .keys ()) # type: ignore[arg-type]
174+ for iodepth_value in test [iodepth_key ]:
175+ self ._iodepth_per_volume = self ._calculate_iodepth_per_volume (
176+ int (self .volumes_per_client ), int (iodepth_value ), iodepth_key
177+ )
176178 self .mode = test ['mode' ]
177179 if 'op_size' in test :
178180 self .op_size = test ['op_size' ]
@@ -183,7 +185,8 @@ def run_workloads(self):
183185 f'iodepth-{ int (self .iodepth ):03d} /numjobs-{ int (self .numjobs ):03d} ' )
184186 common .make_remote_dir (self .run_dir )
185187
186- for i in range (self .volumes_per_client ):
188+ number_of_volumes : int = len (self ._iodepth_per_volume .keys ())
189+ for i in range (number_of_volumes ):
187190 fio_cmd = self .mkfiocmd (i )
188191 p = common .pdsh (settings .getnodes ('clients' ), fio_cmd )
189192 ps .append (p )
@@ -235,7 +238,8 @@ def run(self):
235238 monitoring .start (self .run_dir )
236239 logger .info ('Running rbd fio %s test.' , self .mode )
237240 ps = []
238- for i in range (self .volumes_per_client ):
241+ number_of_volumes : int = len (self ._iodepth_per_volume .keys ())
242+ for i in range (number_of_volumes ):
239243 fio_cmd = self .mkfiocmd (i )
240244 p = common .pdsh (settings .getnodes ('clients' ), fio_cmd )
241245 ps .append (p )
@@ -284,10 +288,8 @@ def mkfiocmd(self, volnum: int) -> str:
284288 fio_cmd += ' --direct=1'
285289 fio_cmd += ' --bs=%dB' % self .op_size
286290
287- iodepth : str = f"{ self .iodepth } "
288- if self ._ioddepth_per_volume != {}:
289- iodepth = f"{ self ._ioddepth_per_volume [volnum ]} "
290-
291+ iodepth : str = f"{ self ._iodepth_per_volume [volnum ]} "
292+
291293 fio_cmd += ' --iodepth=%s' % iodepth
292294 fio_cmd += ' --end_fsync=%d' % self .end_fsync
293295# if self.vol_size:
@@ -415,7 +417,33 @@ def analyze(self, out_dir):
415417 logger .info ('Convert results to json format.' )
416418 self .parse (out_dir )
417419
418- def _calculate_iodepth_per_volume (self , number_of_volumes : int , total_desired_iodepth : int ) -> dict [int , int ]:
420+ def _get_iodepth_key (self , configuration_keys : list [str ]) -> str :
421+ """
422+ Get the string that represents the key to use when reading the iodepth
423+ values from the configuration. This will be 'total_iodepth' if it is
424+ present, otherwise iodepth
425+ """
426+ iodepth_key : str = "iodepth"
427+ if "total_iodepth" in configuration_keys :
428+ iodepth_key = "total_iodepth"
429+
430+ return iodepth_key
431+
432+ def _calculate_iodepth_per_volume (self , number_of_volumes : int , iodepth : int , iodepth_key : str ) -> dict [int , int ]:
433+ """
434+ Calculate the desired iodepth per volume for a single benchmark run.
435+ If total_iodepth is to be used calculate what the iodepth per volume
436+ should be and return that, otherwise return the iodepth value for each
437+ volume
438+ """
439+ if iodepth_key == "total_iodepth" :
440+ return self ._calculate_iodepth_per_volume_from_total_iodepth (number_of_volumes , iodepth )
441+ else :
442+ return self ._set_iodepth_for_every_volume (number_of_volumes , iodepth )
443+
444+ def _calculate_iodepth_per_volume_from_total_iodepth (
445+ self , number_of_volumes : int , total_desired_iodepth : int
446+ ) -> dict [int , int ]:
419447 """
420448 Given the total desired iodepth and the number of volumes from the
421449 configuration yaml file, calculate the iodepth for each volume
@@ -436,7 +464,6 @@ def _calculate_iodepth_per_volume(self, number_of_volumes: int, total_desired_io
436464 "Number of volumes per client will be reduced from %s to %s" , number_of_volumes , total_desired_iodepth
437465 )
438466 number_of_volumes = total_desired_iodepth
439- self .volumes_per_client = number_of_volumes
440467
441468 iodepth_per_volume : int = total_desired_iodepth // number_of_volumes
442469 remainder : int = total_desired_iodepth % number_of_volumes
@@ -451,5 +478,16 @@ def _calculate_iodepth_per_volume(self, number_of_volumes: int, total_desired_io
451478
452479 return queue_depths
453480
481+ def _set_iodepth_for_every_volume (self , number_of_volumes : int , iodepth : int ) -> dict [int , int ]:
482+ """
483+ Given an iodepth value and the number of volumes return a dictionary
484+ that contains the desired iodepth value for each volume
485+ """
486+ queue_depths : dict [int , int ] = {}
487+ for volume_id in range (number_of_volumes ):
488+ queue_depths [volume_id ] = iodepth
489+
490+ return queue_depths
491+
454492 def __str__ (self ):
455493 return "%s\n %s\n %s" % (self .run_dir , self .out_dir , super (LibrbdFio , self ).__str__ ())
0 commit comments