in perfkitbenchmarker/linux_packages/mutilate.py [0:0]
def Run(vms, server_ip, server_port, num_instances):
"""Runs the mutilate benchmark on the vm."""
samples = []
master = vms[0]
runtime_options = {}
samples = []
measure_flags = []
additional_flags = ['--%s' % option for option in FLAGS.mutilate_options]
if FLAGS.mutilate_measure_connections:
runtime_options['measure_connections'] = FLAGS.mutilate_measure_connections
measure_flags.append(
'--measure_connections=%s' % FLAGS.mutilate_measure_connections
)
if FLAGS.mutilate_measure_threads:
runtime_options['measure_threads'] = FLAGS.mutilate_measure_threads
if FLAGS.mutilate_measure_qps:
runtime_options['measure_qps'] = FLAGS.mutilate_measure_qps
measure_flags.append('--measure_qps=%s' % FLAGS.mutilate_measure_qps)
if FLAGS.mutilate_measure_depth:
runtime_options['measure_depth'] = FLAGS.mutilate_measure_depth
measure_flags.append('--measure_depth=%s' % FLAGS.mutilate_measure_depth)
for thread_count in FLAGS.mutilate_threads:
runtime_options['threads'] = thread_count
for vm in vms[1:]:
RestartAgent(vm, thread_count)
for connection_count in FLAGS.mutilate_connections:
runtime_options['connections'] = connection_count
for depth in FLAGS.mutilate_depths:
runtime_options['depth'] = depth
target_qps_list = FLAGS.mutilate_qps[:] or [0]
while True:
target_qps = int(target_qps_list[0])
runtime_options['qps'] = target_qps or 'peak'
remote_agents = ['--agent=%s' % vm.internal_ip for vm in vms[1:]]
cmd = BuildCmd(
server_ip,
server_port,
num_instances,
[
'--noload',
'--qps=%s' % target_qps,
'--time=%s' % FLAGS.mutilate_time,
'--update=%s' % FLAGS.mutilate_ratio,
'--threads=%s'
% (FLAGS.mutilate_measure_threads or thread_count),
'--connections=%s' % connection_count,
'--depth=%s' % depth,
]
+ remote_agents
+ measure_flags
+ additional_flags,
)
try:
stdout, _, retcode = master.RemoteHostCommandWithReturnCode(
' '.join(cmd),
timeout=FLAGS.mutilate_time * 2,
ignore_failure=True,
)
except errors.VmUtil.IssueCommandTimeoutError:
break
if retcode:
break
metadata = GetMetadata()
metadata.update(runtime_options)
run_samples, actual_qps = ParseResults(stdout, metadata)
samples.extend(run_samples)
if _INCREMENTAL_LOAD.value and (
actual_qps / target_qps > (1 - _INCREMENTAL_LOAD.value * 2)
):
target_qps_list.append(
int(target_qps) * (1 + _INCREMENTAL_LOAD.value)
)
target_qps_list.pop(0)
if not target_qps_list:
break
return samples