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 {
unsigned refcnt;
unsigned xid;
struct objhead *objhead;
struct storage *objstore;
struct ws ws_o[1];
unsigned char *vary;
......@@ -448,7 +449,7 @@ int EXP_NukeOne(struct sess *sp);
int Fetch(struct sess *sp);
/* 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);
void HSH_Copy(const struct sess *sp, const struct objhead *o);
struct object *HSH_Lookup(struct sess *sp);
......
......@@ -259,7 +259,6 @@ Fetch(struct sess *sp)
struct storage *st;
struct bereq *bereq;
int mklen, is_head;
unsigned len;
struct http_conn htc[1];
int i;
......@@ -276,6 +275,13 @@ Fetch(struct sess *sp)
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);
if (vc == NULL)
return (1);
......@@ -310,13 +316,6 @@ Fetch(struct sess *sp)
/* Filter into object */
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;
http_CopyResp(hp2, hp);
......
......@@ -67,9 +67,10 @@ static struct hash_slinger *hash;
/* Precreate an objhead and object for later use */
void
HSH_Prealloc(const struct sess *sp)
HSH_Prealloc(struct sess *sp)
{
struct worker *w;
struct storage *st;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
w = sp->wrk;
......@@ -84,8 +85,12 @@ HSH_Prealloc(const struct sess *sp)
} else
CHECK_OBJ_NOTNULL(w->nobjhead, OBJHEAD_MAGIC);
if (w->nobj == NULL) {
w->nobj = calloc(sizeof *w->nobj, 1);
XXXAN(w->nobj);
st = STV_alloc(sp, params->mem_workspace);
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->http->magic = HTTP_MAGIC;
w->nobj->busy = 1;
......@@ -304,14 +309,11 @@ HSH_Deref(struct object *o)
if (r != 0)
return;
if (o->http->ws != NULL && o->http->ws->s != NULL)
free(o->http->ws->s);
if (o->vary != NULL)
free(o->vary);
HSH_Freestore(o);
FREE_OBJ(o);
STV_free(o->objstore);
VSL_stats->n_object--;
if (oh == NULL)
......
......@@ -56,6 +56,7 @@
#include "vcl.h"
#include "cli_priv.h"
#include "cache.h"
#include "stevedore.h"
VTAILQ_HEAD(workerhead, worker);
......@@ -261,7 +262,7 @@ wrk_thread(void *priv)
FREE_OBJ(w->nobjhead);
}
if (w->nobj!= NULL)
FREE_OBJ(w->nobj);
STV_free(w->nobj->objstore);
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