Commit 64bc63a5 authored by Martin Karsten's avatar Martin Karsten
Browse files

- move 'open_bundle' from thread to connection

parent fc15a8bd
......@@ -991,7 +991,7 @@ void resp_add_chunked_iov(mc_resp *resp, const void *buf, int len) {
static mc_resp* resp_allocate(conn *c) {
LIBEVENT_THREAD *th = currthread;
mc_resp *resp = NULL;
mc_resp_bundle *b = th->open_bundle;
mc_resp_bundle *b = c->open_bundle;
if (b != NULL) {
for (int i = 0; i < MAX_RESP_PER_BUNDLE; i++) {
......@@ -1010,7 +1010,7 @@ static mc_resp* resp_allocate(conn *c) {
if (b->refcount == MAX_RESP_PER_BUNDLE) {
assert(b->prev == NULL);
// We only allocate off the head. Assign new head.
th->open_bundle = b->next;
c->open_bundle = b->next;
// Remove ourselves from the list.
if (b->next) {
b->next->prev = 0;
......@@ -1021,7 +1021,7 @@ static mc_resp* resp_allocate(conn *c) {
}
if (resp == NULL) {
assert(th->open_bundle == NULL);
assert(c->open_bundle == NULL);
b = do_cache_alloc(th->rbuf_cache);
if (b) {
THR_STATS_LOCK(c);
......@@ -1035,7 +1035,7 @@ static mc_resp* resp_allocate(conn *c) {
}
b->next = 0;
b->prev = 0;
th->open_bundle = b;
c->open_bundle = b;
resp = &b->r[0];
resp->free = false;
} else {
......@@ -1053,16 +1053,16 @@ static void resp_free(conn *c, mc_resp *resp) {
resp->free = true;
b->refcount--;
if (b->refcount == 0) {
if (b == th->open_bundle && b->next == 0) {
if (b == c->open_bundle && b->next == 0) {
// This is the final bundle. Just hold and reuse to skip init loop
assert(b->prev == 0);
b->next_check = 0;
} else {
// Assert that we're either in the list or at the head.
assert((b->next || b->prev) || b == th->open_bundle);
assert((b->next || b->prev) || b == c->open_bundle);
// unlink from list.
mc_resp_bundle **head = &th->open_bundle;
mc_resp_bundle **head = &c->open_bundle;
if (*head == b) *head = b->next;
// Not tracking the tail.
assert(b->next != b && b->prev != b);
......@@ -1077,9 +1077,9 @@ static void resp_free(conn *c, mc_resp *resp) {
THR_STATS_UNLOCK(c);
}
} else {
mc_resp_bundle **head = &th->open_bundle;
mc_resp_bundle **head = &c->open_bundle;
// NOTE: since we're not tracking tail, latest free ends up in head.
if (b == th->open_bundle || (b->prev || b->next)) {
if (b == c->open_bundle || (b->prev || b->next)) {
// If we're already linked, leave it in place to save CPU.
} else {
// Non-zero refcount, need to link into the freelist.
......
......@@ -606,7 +606,6 @@ typedef struct {
pthread_t thread_id; /* unique ID of this thread */
struct thread_stats stats; /* Stats generated by this thread */
cache_t *rbuf_cache; /* static-sized read buffers */
mc_resp_bundle *open_bundle;
cache_t *io_cache; /* IO objects */
#ifdef EXTSTORE
void *storage; /* data object for storage system */
......@@ -728,6 +727,7 @@ struct conn {
int rsize; /** total allocated size of rbuf */
int rbytes; /** how much data, starting from rcur, do we have unparsed */
mc_resp_bundle *open_bundle;
mc_resp *resp; // tail response.
mc_resp *resp_head; // first response in current stack.
char *ritem; /** when we read in an item's value, it goes here */
......
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