From 6426c00d73d0e9df9e7d87b2968a52bcd5b43898 Mon Sep 17 00:00:00 2001 From: Derek Phanekham Date: Wed, 8 Apr 2020 19:22:30 -0500 Subject: [PATCH] change iperf sending thread count to a list --- .../linux_benchmarks/iperf_benchmark.py | 57 ++++++++++--------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/perfkitbenchmarker/linux_benchmarks/iperf_benchmark.py b/perfkitbenchmarker/linux_benchmarks/iperf_benchmark.py index 92b9e5de6d..230131a0ce 100644 --- a/perfkitbenchmarker/linux_benchmarks/iperf_benchmark.py +++ b/perfkitbenchmarker/linux_benchmarks/iperf_benchmark.py @@ -27,11 +27,13 @@ from perfkitbenchmarker import flags from perfkitbenchmarker import sample from perfkitbenchmarker import vm_util +from perfkitbenchmarker import flag_util -flags.DEFINE_integer('iperf_sending_thread_count', 1, - 'Number of connections to make to the ' - 'server for sending traffic.', - lower_bound=1) +flag_util.DEFINE_integerlist('iperf_sending_thread_count', + flag_util.IntegerList([1]), + 'server for sending traffic. Iperf' + 'will run once for each value in the list', + module_name=__name__) flags.DEFINE_integer('iperf_runtime_in_seconds', 60, 'Number of seconds to run iperf.', lower_bound=1) @@ -86,7 +88,7 @@ def Prepare(benchmark_spec): @vm_util.Retry(max_retries=IPERF_RETRIES) -def _RunIperf(sending_vm, receiving_vm, receiving_ip_address, ip_type): +def _RunIperf(sending_vm, receiving_vm, receiving_ip_address, thread_count, ip_type): """Run iperf using sending 'vm' to connect to 'ip_address'. Args: @@ -100,10 +102,10 @@ def _RunIperf(sending_vm, receiving_vm, receiving_ip_address, ip_type): iperf_cmd = ('iperf --client %s --port %s --format m --time %s -P %s' % (receiving_ip_address, IPERF_PORT, FLAGS.iperf_runtime_in_seconds, - FLAGS.iperf_sending_thread_count)) + thread_count)) # the additional time on top of the iperf runtime is to account for the # time it takes for the iperf process to start and exit - timeout_buffer = FLAGS.iperf_timeout or 30 + FLAGS.iperf_sending_thread_count + timeout_buffer = FLAGS.iperf_timeout or 30 + thread_count stdout, _ = sending_vm.RemoteCommand(iperf_cmd, should_log=True, timeout=FLAGS.iperf_runtime_in_seconds + timeout_buffer) @@ -131,10 +133,10 @@ def _RunIperf(sending_vm, receiving_vm, receiving_ip_address, ip_type): # below will tend to overestimate a bit. thread_values = re.findall('\[.*\d+\].*\s+(\d+\.?\d*).Mbits/sec', stdout) - if len(thread_values) != FLAGS.iperf_sending_thread_count: + if len(thread_values) != thread_count: raise ValueError('Only %s out of %s iperf threads reported a' ' throughput value.' % - (len(thread_values), FLAGS.iperf_sending_thread_count)) + (len(thread_values), thread_count)) total_throughput = 0.0 for value in thread_values: @@ -145,7 +147,7 @@ def _RunIperf(sending_vm, receiving_vm, receiving_ip_address, ip_type): 'receiving_machine_type': receiving_vm.machine_type, 'receiving_zone': receiving_vm.zone, 'sending_machine_type': sending_vm.machine_type, - 'sending_thread_count': FLAGS.iperf_sending_thread_count, + 'sending_thread_count': thread_count, 'sending_zone': sending_vm.zone, 'runtime_in_seconds': FLAGS.iperf_runtime_in_seconds, 'ip_type': ip_type @@ -168,22 +170,25 @@ def Run(benchmark_spec): logging.info('Iperf Results:') - # Send traffic in both directions - for sending_vm, receiving_vm in vms, reversed(vms): - # Send using external IP addresses - if vm_util.ShouldRunOnExternalIpAddress(): - results.append(_RunIperf(sending_vm, - receiving_vm, - receiving_vm.ip_address, - 'external')) - - # Send using internal IP addresses - if vm_util.ShouldRunOnInternalIpAddress(sending_vm, - receiving_vm): - results.append(_RunIperf(sending_vm, - receiving_vm, - receiving_vm.internal_ip, - 'internal')) + for thread_count in FLAGS.iperf_sending_thread_count: + # Send traffic in both directions + for sending_vm, receiving_vm in vms, reversed(vms): + # Send using external IP addresses + if vm_util.ShouldRunOnExternalIpAddress(): + results.append(_RunIperf(sending_vm, + receiving_vm, + receiving_vm.ip_address, + thread_count, + 'external')) + + # Send using internal IP addresses + if vm_util.ShouldRunOnInternalIpAddress(sending_vm, + receiving_vm): + results.append(_RunIperf(sending_vm, + receiving_vm, + receiving_vm.internal_ip, + thread_count, + 'internal')) return results