From 80ad5db6645f1a80a92acfc740aad6fc65214cf7 Mon Sep 17 00:00:00 2001 From: Yanting Yu Date: Mon, 11 Dec 2023 16:38:12 -0800 Subject: [PATCH] Specify sending ip for netperf on large machines. PiperOrigin-RevId: 589990789 --- .../linux_benchmarks/netperf_benchmark.py | 12 +++++++++--- tests/linux_benchmarks/netperf_benchmark_test.py | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/perfkitbenchmarker/linux_benchmarks/netperf_benchmark.py b/perfkitbenchmarker/linux_benchmarks/netperf_benchmark.py index f3ca9f4c4c..6f66803136 100644 --- a/perfkitbenchmarker/linux_benchmarks/netperf_benchmark.py +++ b/perfkitbenchmarker/linux_benchmarks/netperf_benchmark.py @@ -427,7 +427,7 @@ def ParseNetperfOutput( return (throughput_sample, latency_samples, latency_hist) -def RunNetperf(vm, benchmark_name, server_ips, num_streams): +def RunNetperf(vm, benchmark_name, server_ips, num_streams, client_ips): """Spawns netperf on a remote VM, parses results. Args: @@ -435,6 +435,7 @@ def RunNetperf(vm, benchmark_name, server_ips, num_streams): benchmark_name: The netperf benchmark to run, see the documentation. server_ips: A list of ips for a machine that is running netserver. num_streams: The number of netperf client threads to run. + client_ips: A list of ips for a machine that is running netperf. Returns: A sample.Sample object with the result. @@ -468,13 +469,16 @@ def RunNetperf(vm, benchmark_name, server_ips, num_streams): remote_cmd_list = [] assert server_ips, 'Server VM does not have an IP to use for netperf.' + if len(client_ips) != len(server_ips): + logging.warning('Number of client and server IPs do not match.') for server_ip_idx, server_ip in enumerate(server_ips): + client_ip = client_ips[server_ip_idx % len(client_ips)] netperf_cmd = ( f'{netperf.NETPERF_PATH} ' '-p {command_port} ' f'-j {verbosity} ' f'-t {benchmark_name} ' - f'-H {server_ip} ' + f'-H {server_ip} -L {client_ip} ' f'-l {FLAGS.netperf_test_length} {confidence}' ' -- ' '-P ,{data_port} ' @@ -679,7 +683,8 @@ def RunClientServerVMs(client_vm, server_vm): for netperf_benchmark in FLAGS.netperf_benchmarks: if vm_util.ShouldRunOnExternalIpAddress(): external_ip_results = RunNetperf( - client_vm, netperf_benchmark, [server_vm.ip_address], num_streams + client_vm, netperf_benchmark, [server_vm.ip_address], num_streams, + [client_vm.ip_address] ) for external_ip_result in external_ip_results: external_ip_result.metadata['ip_type'] = ( @@ -694,6 +699,7 @@ def RunClientServerVMs(client_vm, server_vm): netperf_benchmark, server_vm.GetInternalIPs(), num_streams, + client_vm.GetInternalIPs() ) for internal_ip_result in internal_ip_results: internal_ip_result.metadata.update(metadata) diff --git a/tests/linux_benchmarks/netperf_benchmark_test.py b/tests/linux_benchmarks/netperf_benchmark_test.py index 3b68283b74..6719e3e914 100644 --- a/tests/linux_benchmarks/netperf_benchmark_test.py +++ b/tests/linux_benchmarks/netperf_benchmark_test.py @@ -79,6 +79,7 @@ def testExternalAndInternal(self): vm_spec.vms[0].RobustRemoteCommand.side_effect = [ (i, '') for i in self.expected_stdout] vm_spec.vms[1].GetInternalIPs.return_value = ['test_ip'] + vm_spec.vms[0].GetInternalIPs.return_value = ['test_ip'] run_result = netperf_benchmark.Run(vm_spec) result = [] for sample in run_result: