Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase connection.wbuf size from 64k to 1m #16

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions mc-crusher.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@

#define SHARED_RBUF_SIZE 1024 * 64
#define SHARED_VALUE_SIZE 1024 * 1024
#define MIN_WBUF_SIZE 65536
// avoiding some hacks for finding member size.
#define SOCK_MAX 100

Expand Down Expand Up @@ -152,7 +153,7 @@ struct connection {
int (*ascii_format)(struct connection *c);
int (*bin_format)(struct connection *c);
int (*bin_prep_cmd)(struct connection *c);
unsigned char wbuf[65536]; // putting this at the end to get more of the above into fewer cachelines.
unsigned char *wbuf;
};

static void client_handler(const int fd, const short which, void *arg);
Expand Down Expand Up @@ -544,7 +545,7 @@ static inline void run_write(struct connection *c) {
}
{
// not using iovecs, save some libc/kernel looping.
c->wbuf_towrite = c->wbuf_pos - (unsigned char *)&c->wbuf;
c->wbuf_towrite = c->wbuf_pos - c->wbuf;
c->wbuf_written = 0;
//fprintf(stderr, "WBUF towrite: %d\n", c->wbuf_towrite);
write_flat(c, c->next_state);
Expand Down Expand Up @@ -1040,6 +1041,13 @@ static void start_template(struct connection *template, int conns_tomake, bool u
*template->cur_key = 0;
*template->write_count = 0;

size_t wbuf_size = template->value_size + 1024; // space for op, key and metadata
if( wbuf_size < MIN_WBUF_SIZE ){
wbuf_size = MIN_WBUF_SIZE;
}
template->wbuf = (unsigned char*)malloc(wbuf_size);
memset(template->wbuf, 0, wbuf_size);

int i, newsock;
for (i = 0; i < conns_tomake; i++) {
if (use_sock) {
Expand Down