Skip to content

Commit

Permalink
Add recv_buffer and send_buffer to benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
PickingUpPieces committed Mar 13, 2024
1 parent 22fd495 commit dde8f48
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
8 changes: 4 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"env": {
"RUST_LOG": "TRACE",
},
"args": ["client", "--with-msg", "--single-socket", "--parallel", "2"],
"args": ["client", "--with-msg"],
"cwd": "${workspaceFolder}",
"preLaunchTask": "delay"
},
Expand All @@ -44,7 +44,7 @@
"env": {
"RUST_LOG": "TRACE",
},
"args": ["server", "--with-msg", "--single-socket", "--parallel", "2"],
"args": ["server", "--with-msg"],
"cwd": "${workspaceFolder}"
},
{
Expand All @@ -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"
Expand All @@ -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,
},
Expand Down
10 changes: 6 additions & 4 deletions benchmarks/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)

Expand Down
6 changes: 3 additions & 3 deletions src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit dde8f48

Please sign in to comment.