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

Move the workerthreads log from malloc to stack.

Dump sizes of various structures on startup.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@2072 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent a72bf08a
...@@ -176,9 +176,8 @@ struct worker { ...@@ -176,9 +176,8 @@ struct worker {
struct srcaddr *srcaddr; struct srcaddr *srcaddr;
struct acct acct; struct acct acct;
unsigned char *wlp, *wle; unsigned char *wlb, *wlp, *wle;
unsigned wlr; unsigned wlr;
unsigned char wlog[WLOGSPACE];
}; };
struct workreq { struct workreq {
......
...@@ -165,6 +165,7 @@ exp_prefetch(void *arg) ...@@ -165,6 +165,7 @@ exp_prefetch(void *arg)
double t; double t;
struct sess *sp; struct sess *sp;
struct object *o2; struct object *o2;
unsigned char log[1024]; /* XXX size ? */
(void)arg; (void)arg;
...@@ -172,8 +173,8 @@ exp_prefetch(void *arg) ...@@ -172,8 +173,8 @@ exp_prefetch(void *arg)
XXXAN(sp); XXXAN(sp);
sp->wrk = &ww; sp->wrk = &ww;
ww.magic = WORKER_MAGIC; ww.magic = WORKER_MAGIC;
ww.wlp = ww.wlog; ww.wlp = ww.wlb = log;
ww.wle = ww.wlog + sizeof ww.wlog; ww.wle = log + sizeof log;
AZ(sleep(10)); /* XXX: Takes time for VCL to arrive */ AZ(sleep(10)); /* XXX: Takes time for VCL to arrive */
VCL_Get(&sp->vcl); VCL_Get(&sp->vcl);
......
...@@ -51,6 +51,22 @@ child_main(void) ...@@ -51,6 +51,22 @@ child_main(void)
setbuf(stderr, NULL); setbuf(stderr, NULL);
printf("Child starts\n"); printf("Child starts\n");
#define SZOF(foo) printf("sizeof(%s) = %d\n", #foo, sizeof(foo));
SZOF(struct ws);
SZOF(struct http);
SZOF(struct http_conn);
SZOF(struct acct);
SZOF(struct worker);
SZOF(struct workreq);
SZOF(struct bereq);
SZOF(struct storage);
SZOF(struct object);
SZOF(struct objhead);
SZOF(struct sess);
SZOF(struct vbe_conn);
SZOF(struct backend);
CNT_Init(); CNT_Init();
VCL_Init(); VCL_Init();
......
...@@ -202,13 +202,14 @@ wrk_thread(void *priv) ...@@ -202,13 +202,14 @@ wrk_thread(void *priv)
struct worker w[1]; struct worker w[1];
struct wq *qp; struct wq *qp;
char c; char c;
unsigned char wlog[8192]; /* XXX: size */
qp = priv; qp = priv;
memset(w, 0, sizeof *w); memset(w, 0, sizeof *w);
w->magic = WORKER_MAGIC; w->magic = WORKER_MAGIC;
w->used = TIM_real(); w->used = TIM_real();
w->wlp = w->wlog; w->wlb = w->wlp = wlog;
w->wle = w->wlog + sizeof w->wlog; w->wle = wlog + sizeof wlog;
AZ(pipe(w->pipe)); AZ(pipe(w->pipe));
VSL(SLT_WorkThread, 0, "%p start", w); VSL(SLT_WorkThread, 0, "%p start", w);
......
...@@ -175,7 +175,7 @@ WSL_Flush(struct worker *w) ...@@ -175,7 +175,7 @@ WSL_Flush(struct worker *w)
unsigned char *p; unsigned char *p;
unsigned l; unsigned l;
l = pdiff(w->wlog, w->wlp); l = pdiff(w->wlb, w->wlp);
if (l == 0) if (l == 0)
return; return;
LOCKSHM(&vsl_mtx); LOCKSHM(&vsl_mtx);
...@@ -184,14 +184,14 @@ WSL_Flush(struct worker *w) ...@@ -184,14 +184,14 @@ WSL_Flush(struct worker *w)
if (loghead->ptr + l + 1 >= loghead->size) if (loghead->ptr + l + 1 >= loghead->size)
vsl_wrap(); vsl_wrap();
p = logstart + loghead->ptr; p = logstart + loghead->ptr;
memcpy(p + 1, w->wlog + 1, l - 1); memcpy(p + 1, w->wlb + 1, l - 1);
p[l] = SLT_ENDMARKER; p[l] = SLT_ENDMARKER;
loghead->ptr += l; loghead->ptr += l;
assert(loghead->ptr < loghead->size); assert(loghead->ptr < loghead->size);
/* XXX: memory barrier here */ /* XXX: memory barrier here */
p[0] = w->wlog[0]; p[0] = w->wlb[0];
UNLOCKSHM(&vsl_mtx); UNLOCKSHM(&vsl_mtx);
w->wlp = w->wlog; w->wlp = w->wlb;
w->wlr = 0; w->wlr = 0;
} }
......
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