Commit f63eeafe authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Move the objects and their http header into storage instead of

malloc'ing them.

This should reduce the N(nobj) swap-loading considerably.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@2073 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent bd7ea6ed
...@@ -222,6 +222,7 @@ struct object { ...@@ -222,6 +222,7 @@ struct object {
unsigned refcnt; unsigned refcnt;
unsigned xid; unsigned xid;
struct objhead *objhead; struct objhead *objhead;
struct storage *objstore;
struct ws ws_o[1]; struct ws ws_o[1];
unsigned char *vary; unsigned char *vary;
...@@ -448,7 +449,7 @@ int EXP_NukeOne(struct sess *sp); ...@@ -448,7 +449,7 @@ int EXP_NukeOne(struct sess *sp);
int Fetch(struct sess *sp); int Fetch(struct sess *sp);
/* cache_hash.c */ /* cache_hash.c */
void HSH_Prealloc(const struct sess *sp); void HSH_Prealloc(struct sess *sp);
int HSH_Compare(const struct sess *sp, const struct objhead *o); int HSH_Compare(const struct sess *sp, const struct objhead *o);
void HSH_Copy(const struct sess *sp, const struct objhead *o); void HSH_Copy(const struct sess *sp, const struct objhead *o);
struct object *HSH_Lookup(struct sess *sp); struct object *HSH_Lookup(struct sess *sp);
......
...@@ -259,7 +259,6 @@ Fetch(struct sess *sp) ...@@ -259,7 +259,6 @@ Fetch(struct sess *sp)
struct storage *st; struct storage *st;
struct bereq *bereq; struct bereq *bereq;
int mklen, is_head; int mklen, is_head;
unsigned len;
struct http_conn htc[1]; struct http_conn htc[1];
int i; int i;
...@@ -276,6 +275,13 @@ Fetch(struct sess *sp) ...@@ -276,6 +275,13 @@ Fetch(struct sess *sp)
sp->obj->xid = sp->xid; sp->obj->xid = sp->xid;
/* Set up obj's workspace */
st = sp->obj->objstore;
WS_Init(sp->obj->ws_o, st->ptr + st->len, st->space - st->len);
st->len = st->space;
WS_Assert(sp->obj->ws_o);
http_Setup(sp->obj->http, sp->obj->ws_o);
vc = VBE_GetFd(sp); vc = VBE_GetFd(sp);
if (vc == NULL) if (vc == NULL)
return (1); return (1);
...@@ -310,13 +316,6 @@ Fetch(struct sess *sp) ...@@ -310,13 +316,6 @@ Fetch(struct sess *sp)
/* Filter into object */ /* Filter into object */
hp2 = sp->obj->http; hp2 = sp->obj->http;
len = Tlen(htc->rxbuf);
len += 256; /* XXX: margin for content-length etc */
b = malloc(len);
AN(b);
WS_Init(sp->obj->ws_o, b, len);
http_Setup(hp2, sp->obj->ws_o);
hp2->logtag = HTTP_Obj; hp2->logtag = HTTP_Obj;
http_CopyResp(hp2, hp); http_CopyResp(hp2, hp);
......
...@@ -67,9 +67,10 @@ static struct hash_slinger *hash; ...@@ -67,9 +67,10 @@ static struct hash_slinger *hash;
/* Precreate an objhead and object for later use */ /* Precreate an objhead and object for later use */
void void
HSH_Prealloc(const struct sess *sp) HSH_Prealloc(struct sess *sp)
{ {
struct worker *w; struct worker *w;
struct storage *st;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
w = sp->wrk; w = sp->wrk;
...@@ -84,8 +85,12 @@ HSH_Prealloc(const struct sess *sp) ...@@ -84,8 +85,12 @@ HSH_Prealloc(const struct sess *sp)
} else } else
CHECK_OBJ_NOTNULL(w->nobjhead, OBJHEAD_MAGIC); CHECK_OBJ_NOTNULL(w->nobjhead, OBJHEAD_MAGIC);
if (w->nobj == NULL) { if (w->nobj == NULL) {
w->nobj = calloc(sizeof *w->nobj, 1); st = STV_alloc(sp, params->mem_workspace);
XXXAN(w->nobj); XXXAN(st);
w->nobj = (void *)st->ptr;
st->len = sizeof *w->nobj;
memset(w->nobj, 0, sizeof *w->nobj);
w->nobj->objstore = st;
w->nobj->magic = OBJECT_MAGIC; w->nobj->magic = OBJECT_MAGIC;
w->nobj->http->magic = HTTP_MAGIC; w->nobj->http->magic = HTTP_MAGIC;
w->nobj->busy = 1; w->nobj->busy = 1;
...@@ -304,14 +309,11 @@ HSH_Deref(struct object *o) ...@@ -304,14 +309,11 @@ HSH_Deref(struct object *o)
if (r != 0) if (r != 0)
return; return;
if (o->http->ws != NULL && o->http->ws->s != NULL)
free(o->http->ws->s);
if (o->vary != NULL) if (o->vary != NULL)
free(o->vary); free(o->vary);
HSH_Freestore(o); HSH_Freestore(o);
FREE_OBJ(o); STV_free(o->objstore);
VSL_stats->n_object--; VSL_stats->n_object--;
if (oh == NULL) if (oh == NULL)
......
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
#include "vcl.h" #include "vcl.h"
#include "cli_priv.h" #include "cli_priv.h"
#include "cache.h" #include "cache.h"
#include "stevedore.h"
VTAILQ_HEAD(workerhead, worker); VTAILQ_HEAD(workerhead, worker);
...@@ -261,7 +262,7 @@ wrk_thread(void *priv) ...@@ -261,7 +262,7 @@ wrk_thread(void *priv)
FREE_OBJ(w->nobjhead); FREE_OBJ(w->nobjhead);
} }
if (w->nobj!= NULL) if (w->nobj!= NULL)
FREE_OBJ(w->nobj); STV_free(w->nobj->objstore);
return (NULL); return (NULL);
} }
......
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