Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

- make window size tunable.

  • Loading branch information...
commit 1c42dbe2a72b976a6dfd1ff4254069c3554d3512 1 parent 7595811
@jordansissel jordansissel authored
Showing with 21 additions and 4 deletions.
  1. +2 −1  emitter.c
  2. +2 −0  emitter.h
  3. +8 −0 lumberjack.c
  4. +7 −2 proto.c
  5. +2 −1  proto.h
View
3  emitter.c
@@ -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);
View
2  emitter.h
@@ -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;
};
View
8 lumberjack.c
@@ -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) {
View
9 proto.c
@@ -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. */
View
3  proto.h
@@ -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
*
Please sign in to comment.
Something went wrong with that request. Please try again.