Skip to content

Commit

Permalink
Add possibility to run a workload with 'rw=trim'
Browse files Browse the repository at this point in the history
In order to check the impact of trim operations on
read and write performance diskplorer.py is extended
by the new argument '--run-sequential-trim' that
allows users to enable the additional workload that
trims data written k seconds before (by default k=10).

The default time offset can be changed via the new
parameter: '--trim-offset-time-seconds' that denotes
the offset between write and trim workloads and is
expressed in seconds.

When sequential trim workload is enabled, the additional
write workload that prepares data to be deleted is also run.
Moreover, the original write and read workloads utilize
'offset=' parameter to ensure that they do not use trimmed
data.

Signed-off-by: Patryk Wrobel <[email protected]>
  • Loading branch information
pwrobelse committed Apr 23, 2024
1 parent 5b8a3a1 commit bc07fc3
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
46 changes: 46 additions & 0 deletions diskplorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
help='Directory to place fio job files (default: files will not be kept)')
parser.add_argument('--result-file', type=str, required=True,
help='Results, in fio json+ format')
parser.add_argument('--run-sequential-trim', action='store_true',
help='Run sequential trim workload in addition to read/write ones to check its impact.')
parser.add_argument('--trim-offset-time-seconds', type=int, default=10,
help='Time amount after the written data is trimmed.')

args = parser.parse_args()

Expand Down Expand Up @@ -93,6 +97,12 @@ def split_among(count, among, dont_bother_below=1):
yield this_count
count -= this_count
among -= 1

def align_up(number, alignment):
if number % alignment == 0:
return number
else:
return (number - (number % alignment)) + alignment

def run_jobs():
def job_files():
Expand Down Expand Up @@ -205,7 +215,29 @@ def global_section():
job_names = generate_job_names(f'job(r_idx={read_iops_step},w_idx={write_bw_step},write_bw={write_bw},r_iops={read_iops})')
read_iops = max(read_iops, 10) # no point in a write-only test
nr_cpus = args.cpus
read_offset_str = ''

if write_bw > 0:
if args.run_sequential_trim:
out(textwrap.dedent(f'''\
[prepare_data_for_trim(r_idx={read_iops_step},w_idx={write_bw_step},write_bw={write_bw},r_iops={read_iops})]
'''))
out(group_introducer)
out(textwrap.dedent(f'''\
readwrite=write
runtime={args.trim_offset_time_seconds}s
blocksize={args.write_buffer_size}
iodepth={args.write_concurrency}
rate={write_bw}
'''))
read_offset = write_bw*(args.test_step_time_seconds+args.trim_offset_time_seconds)
read_offset_str = f'offset={align_up(read_offset, args.read_buffer_size)}'
write_offset = write_bw*args.trim_offset_time_seconds
write_offset_str = f'offset={align_up(write_offset, args.write_buffer_size)}'
else:
read_offset_str = ''
write_offset_str = ''

out(textwrap.dedent(f'''\
[{next(job_names)}]
'''))
Expand All @@ -215,7 +247,20 @@ def global_section():
blocksize={args.write_buffer_size}
iodepth={args.write_concurrency}
rate={write_bw}
{write_offset_str}
'''))

if args.run_sequential_trim:
out(textwrap.dedent(f'''\
[trim_data(r_idx={read_iops_step},w_idx={write_bw_step},write_bw={write_bw},r_iops={read_iops})]
'''))
out(textwrap.dedent(f'''\
readwrite=trim
blocksize={align_up(int(write_bw*args.trim_offset_time_seconds/2), 4096)}
iodepth={args.write_concurrency}
rate={write_bw}
'''))

nr_cpus -= 1
read_group_introducer = ''
else:
Expand All @@ -232,6 +277,7 @@ def global_section():
iodepth={args.read_concurrency}
rate_iops={this_cpu_read_iops}
rate_process=poisson
{read_offset_str}
'''))
yield run(file)

Expand Down
2 changes: 1 addition & 1 deletion latency-postprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

for j in jobs:
name = j['jobname']
if name == 'prepare':
if name == 'prepare' or name.startswith('prepare_data_for_trim') or name.startswith('trim_data'):
continue
m = re.match(r'job\(r_idx=(\d+),w_idx=(\d+),write_bw=(\d+),r_iops=(\d+)', name)
r_idx, w_idx, w_bw, r_iops = [int(x) for x in m.groups()]
Expand Down

0 comments on commit bc07fc3

Please sign in to comment.