perf: downsized test data, increased SSH socket buffer, and made chunk size configurable
- Reduced test data from 50MB to 25MB (test.py) - Increased SSH socketpair buffer to 1MB via setsockopt (transport_ssh.c) - Made chunk size configurable: new Config field, --chunk-size CLI flag, sent over wire, and used in scanner instead of DESIRED_CHUNK_SIZE - Fixed DESIRED_CHUNK_SIZE macro parentheses (chunk.h)
This commit is contained in:
+1
-1
@@ -6,7 +6,7 @@
|
||||
#include <stdbool.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#define DESIRED_CHUNK_SIZE 10 * 1024 * 1024
|
||||
#define DESIRED_CHUNK_SIZE (10 * 1024 * 1024)
|
||||
|
||||
typedef struct {
|
||||
File **items;
|
||||
|
||||
+5
-1
@@ -10,7 +10,8 @@ Config *config_create(char *version, char *send_directory,
|
||||
char *receive_directory, bool save_to_disk,
|
||||
bool use_multithreading, bool use_chunk_serialization,
|
||||
bool use_compression, bool use_metadata,
|
||||
int compression_level, bool use_sendfile) {
|
||||
int compression_level, bool use_sendfile,
|
||||
unsigned long long chunk_size) {
|
||||
|
||||
Config *config = malloc(sizeof(Config));
|
||||
config->version = version;
|
||||
@@ -23,6 +24,7 @@ Config *config_create(char *version, char *send_directory,
|
||||
config->use_metadata = use_metadata;
|
||||
config->compression_level = compression_level;
|
||||
config->use_sendfile = use_sendfile;
|
||||
config->chunk_size = chunk_size > 0 ? chunk_size : DEFAULT_CHUNK_SIZE;
|
||||
config->transport = TRANSPORT_TCP;
|
||||
config->ssh_destination = NULL;
|
||||
return config;
|
||||
@@ -67,6 +69,7 @@ void config_send(int file_descriptor, Config *config) {
|
||||
send_int(file_descriptor, config->use_compression);
|
||||
send_int(file_descriptor, config->use_metadata);
|
||||
send_int(file_descriptor, config->compression_level);
|
||||
send_int(file_descriptor, (int)config->chunk_size);
|
||||
send_int(file_descriptor, config->use_sendfile);
|
||||
if (receive_status(file_descriptor) != STATUS_OK) {
|
||||
perror("Error transmitting config!");
|
||||
@@ -85,6 +88,7 @@ Config *config_receive(int file_descriptor) {
|
||||
config->use_compression = receive_int(file_descriptor);
|
||||
config->use_metadata = receive_int(file_descriptor);
|
||||
config->compression_level = receive_int(file_descriptor);
|
||||
config->chunk_size = (unsigned long long)receive_int(file_descriptor);
|
||||
config->use_sendfile = receive_int(file_descriptor);
|
||||
config->transport = TRANSPORT_TCP;
|
||||
config->ssh_destination = NULL;
|
||||
|
||||
+5
-1
@@ -19,15 +19,19 @@ typedef struct Config {
|
||||
bool use_sendfile;
|
||||
bool use_metadata;
|
||||
int compression_level;
|
||||
unsigned long long chunk_size;
|
||||
TransportType transport;
|
||||
char *ssh_destination;
|
||||
} Config;
|
||||
|
||||
#define DEFAULT_CHUNK_SIZE (10 * 1024 * 1024)
|
||||
|
||||
Config *config_create(char *version, char *send_directory,
|
||||
char *receive_directory, bool save_to_disk,
|
||||
bool use_multithreading, bool use_chunk_serialization,
|
||||
bool use_compression, bool use_metadata,
|
||||
int compression_level, bool use_sendfile);
|
||||
int compression_level, bool use_sendfile,
|
||||
unsigned long long chunk_size);
|
||||
void config_delete(Config *config);
|
||||
void config_send(int file_descriptor, Config *config);
|
||||
Config *config_receive(int file_descriptor);
|
||||
|
||||
@@ -55,6 +55,12 @@ Client *client_connect_ssh(char *destination) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
int buf_size = 1024 * 1024;
|
||||
setsockopt(sv[0], SOL_SOCKET, SO_SNDBUF, &buf_size, sizeof(buf_size));
|
||||
setsockopt(sv[0], SOL_SOCKET, SO_RCVBUF, &buf_size, sizeof(buf_size));
|
||||
setsockopt(sv[1], SOL_SOCKET, SO_SNDBUF, &buf_size, sizeof(buf_size));
|
||||
setsockopt(sv[1], SOL_SOCKET, SO_RCVBUF, &buf_size, sizeof(buf_size));
|
||||
|
||||
int exec_pipe[2];
|
||||
if (pipe(exec_pipe) < 0) {
|
||||
perror("pipe failed");
|
||||
|
||||
Reference in New Issue
Block a user