Commit 1c42dbe2 authored by Jordan Sissel's avatar Jordan Sissel

- make window size tunable.

parent 7595811e
......@@ -35,8 +35,9 @@ void *emitter(void *arg) {
backoff_init(&sleeper, &MIN_SLEEP, &MAX_SLEEP);
struct lumberjack *lumberjack;
lumberjack = lumberjack_new(config->host, config->port);
lumberjack = lumberjack_new(config->host, config->port, config->window_size);
insist(lumberjack != NULL, "lumberjack_new failed");
lumberjack->ring_size = config->window_size;
if (config->ssl_ca_path != NULL) {
rc = lumberjack_set_ssl_ca(lumberjack, config->ssl_ca_path);
......
......@@ -6,6 +6,8 @@ struct emitter_config {
char *zmq_endpoint; /* inproc://whatever */
char *ssl_ca_path; /* path to trusted ssl ca, can be a directory or a file */
size_t window_size; /* the window size */
char *host;
short port;
};
......
......@@ -24,6 +24,7 @@ typedef enum {
opt_ssl_ca_path,
opt_host,
opt_port,
opt_window_size,
} optlist_t;
struct option_doc {
......@@ -61,6 +62,9 @@ static struct option_doc options[] = {
"by separating hosts with a comma." },
{ "port", required_argument, opt_port,
"The port to connect on the lumberjack server" },
{ "window-size", required_argument, opt_window_size,
"The maximum number of outstanding messages to send before we will " \
"wait for an acknowledgement" },
{ NULL, 0, 0, NULL },
};
......@@ -170,6 +174,10 @@ int main(int argc, char **argv) {
case opt_port:
emitter_config.port = (short)atoi(optarg);
break;
case opt_window_size:
emitter_config.window_size = (size_t)atoi(optarg);
printf("size: %d\n", (int)emitter_config.window_size);
break;
case opt_field:
tmp = strchr(optarg, '=');
if (tmp == NULL) {
......
......@@ -58,7 +58,7 @@ static void lumberjack_init(void) {
lumberjack_init_done = 1;
} /* lumberjack_init */
struct lumberjack *lumberjack_new(const char *host, unsigned short port) {
struct lumberjack *lumberjack_new(const char *host, unsigned short port, size_t window_size) {
struct lumberjack *lumberjack;
lumberjack_init(); /* global one-time init */
......@@ -73,7 +73,12 @@ struct lumberjack *lumberjack_new(const char *host, unsigned short port) {
/* I tried with 128, 256, 512, 1024, 2048, and 16384,
* in a local network, an window size of 1024 seemed to have the best
* performance (equal to 2048 and 16384) for the least memory cost. */
lumberjack->ring_size = 1024; /* TODO(sissel): tunable */
if (window_size < 1024) {
flog(stdout, "Window size less than 1024 (%d) isn't shown to have performance benefits",
window_size);
}
lumberjack->ring_size = window_size; /* TODO(sissel): tunable */
lumberjack->ring = ring_new_size(lumberjack->ring_size);
/* Create this once. */
......
......@@ -43,11 +43,12 @@ struct lumberjack {
*
* - host is a hostname or IP address.
* - port is the port to connect to.
* - window_size is how many events to send before waiting for an ack.
*
* If the hostname resolves to multiple addresses, one address is picked at
* random each time a connection is made.
*/
struct lumberjack *lumberjack_new(const char *host, unsigned short port);
struct lumberjack *lumberjack_new(const char *host, unsigned short port, size_t window_size);
/* Tell lumberjack about an SSL cert/ca it should trust
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment