From dde8f4814f2400208c65315e16380991642230cd Mon Sep 17 00:00:00 2001 From: Vincent Picking Date: Thu, 14 Mar 2024 00:32:15 +0100 Subject: [PATCH] Add recv_buffer and send_buffer to benchmark --- .vscode/launch.json | 8 ++++---- benchmarks/benchmark.py | 10 ++++++---- src/command.rs | 6 +++--- src/lib.rs | 6 ++++-- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 7a4536f..c49e40e 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -22,7 +22,7 @@ "env": { "RUST_LOG": "TRACE", }, - "args": ["client", "--with-msg", "--single-socket", "--parallel", "2"], + "args": ["client", "--with-msg"], "cwd": "${workspaceFolder}", "preLaunchTask": "delay" }, @@ -44,7 +44,7 @@ "env": { "RUST_LOG": "TRACE", }, - "args": ["server", "--with-msg", "--single-socket", "--parallel", "2"], + "args": ["server", "--with-msg"], "cwd": "${workspaceFolder}" }, { @@ -55,7 +55,7 @@ "RUST_LOG": "INFO", }, "program": "${workspaceFolder}/target/debug/nperf", - "args": ["client", "--with-msg", "--single-socket", "--parallel", "2"], + "args": ["client", "--with-msg", "--json"], "cwd": "${workspaceFolder}", "stopOnEntry": false, "preLaunchTask": "delay" @@ -68,7 +68,7 @@ "RUST_LOG": "INFO", }, "program": "${workspaceFolder}/target/debug/nperf", - "args": ["server", "--with-msg", "--single-socket", "--parallel", "2"], + "args": ["server", "--with-msg", "--json"], "cwd": "${workspaceFolder}", "stopOnEntry": false, }, diff --git a/benchmarks/benchmark.py b/benchmarks/benchmark.py index 87a3b86..5d8438a 100644 --- a/benchmarks/benchmark.py +++ b/benchmarks/benchmark.py @@ -12,8 +12,8 @@ logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') PATH_TO_RESULTS_FOLDER = 'results/' -PATH_TO_NPERF_REPO = '/home_stud/picking/repos/nperf' -#PATH_TO_NPERF_REPO = '/opt/nperf' +#PATH_TO_NPERF_REPO = '/home_stud/picking/repos/nperf' +PATH_TO_NPERF_REPO = '/opt/nperf' PATH_TO_NPERF_BIN = PATH_TO_NPERF_REPO + '/target/release/nperf' def parse_config_file(json_file_path): @@ -122,7 +122,7 @@ def run_test(run_config): def write_results_to_csv(test_results, test_name, csv_file_path): # FIXME: If new measurement parameters are added, the header should be updated - header = ['test_name', 'run_number', 'run_name', 'amount_threads_client', 'amount_threads_server', 'amount_used_ports_server', 'test_runtime_length', 'datagram_size', 'packet_buffer_size', 'exchange_function', 'io_model', 'total_data_gbyte', 'amount_datagrams', 'amount_data_bytes', 'amount_reordered_datagrams', 'amount_duplicated_datagrams', 'amount_omitted_datagrams', 'amount_syscalls', 'amount_io_model_syscalls', 'data_rate_gbit', 'packet_loss', 'nonblocking', 'ip_fragmentation', 'gso', 'gro', 'single-socket'] + header = ['test_name', 'run_number', 'run_name', 'amount_threads_client', 'amount_threads_server', 'amount_used_ports_server', 'test_runtime_length', 'datagram_size', 'packet_buffer_size', 'exchange_function', 'io_model', 'total_data_gbyte', 'amount_datagrams', 'amount_data_bytes', 'amount_reordered_datagrams', 'amount_duplicated_datagrams', 'amount_omitted_datagrams', 'amount_syscalls', 'amount_io_model_syscalls', 'data_rate_gbit', 'packet_loss', 'nonblocking', 'ip_fragmentation', 'gso', 'gro', 'single-socket', 'receive_buffer_size', 'send_buffer_size'] file_exists = os.path.isfile(csv_file_path) with open(csv_file_path, 'a', newline='') as csvfile: @@ -163,7 +163,9 @@ def write_results_to_csv(test_results, test_name, csv_file_path): 'ip_fragmentation': client_result['parameter']['socket_options']['ip_fragmentation'], 'gso': client_result['parameter']['socket_options']['gso'], 'gro': server_result['parameter']['socket_options']['gro'], - 'single-socket': server_result['parameter']['single_socket'] + 'single-socket': server_result['parameter']['single_socket'], + 'receive_buffer_size': server_result['parameter']['socket_options']['recv_buffer_size'], + 'send_buffer_size': server_result['parameter']['socket_options']['send_buffer_size'] } writer.writerow(row) diff --git a/src/command.rs b/src/command.rs index d5bb267..89bd716 100644 --- a/src/command.rs +++ b/src/command.rs @@ -282,11 +282,11 @@ impl nPerf { }; let (recv_buffer_size, send_buffer_size) = if self.with_socket_buffer { - info!("Setting udp buffer sizes with recv {} and send {}", crate::DEFAULT_SOCKET_RECEIVE_BUFFER_SIZE, crate::DEFAULT_SOCKET_SEND_BUFFER_SIZE); - (Some(crate::DEFAULT_SOCKET_RECEIVE_BUFFER_SIZE), Some(crate::DEFAULT_SOCKET_SEND_BUFFER_SIZE)) + info!("Setting udp buffer sizes with recv {} and send {}", crate::MAX_SOCKET_RECEIVE_BUFFER_SIZE, crate::MAX_SOCKET_SEND_BUFFER_SIZE); + (Some(crate::MAX_SOCKET_RECEIVE_BUFFER_SIZE), Some(crate::MAX_SOCKET_SEND_BUFFER_SIZE)) } else { info!("Setting buffer size of UDP socket disabled!"); - (None, None) + (Some(crate::DEFAULT_SOCKET_RECEIVE_BUFFER_SIZE), Some(crate::DEFAULT_SOCKET_SEND_BUFFER_SIZE)) }; let gro = mode == util::NPerfMode::Server && self.with_gsro; diff --git a/src/lib.rs b/src/lib.rs index 1f04e4f..8b6b278 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,8 +9,10 @@ pub use util::statistic::Statistic; const DEFAULT_MSS: u32= 1472; const DEFAULT_UDP_DATAGRAM_SIZE: u32 = 1472; const DEFAULT_GSO_BUFFER_SIZE: u32= 65507; -const DEFAULT_SOCKET_SEND_BUFFER_SIZE: u32 = 26214400; // 25MB; // The buffer size will be doubled by the kernel to account for overhead. See man 7 socket -const DEFAULT_SOCKET_RECEIVE_BUFFER_SIZE: u32 = 26214400; // 25MB; // The buffer size will be doubled by the kernel to account for overhead. See man 7 socket +const MAX_SOCKET_SEND_BUFFER_SIZE: u32 = 26214400; // 25MB; // The buffer size will be doubled by the kernel to account for overhead. See man 7 socket +const MAX_SOCKET_RECEIVE_BUFFER_SIZE: u32 = 212992 ; // 25MB; // The buffer size will be doubled by the kernel to account for overhead. See man 7 socket +const DEFAULT_SOCKET_SEND_BUFFER_SIZE: u32 = 212992; +const DEFAULT_SOCKET_RECEIVE_BUFFER_SIZE: u32 = 212992; const DEFAULT_DURATION: u64 = 10; // /* seconds */ const DEFAULT_PORT: u16 = 45001; const WAIT_CONTROL_MESSAGE: u64 = 200; // /* milliseconds */