r2072 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Mon Oct 1 09:46:00 CEST 2007


Author: phk
Date: 2007-10-01 09:45:58 +0200 (Mon, 01 Oct 2007)
New Revision: 2072

Modified:
   trunk/varnish-cache/bin/varnishd/cache.h
   trunk/varnish-cache/bin/varnishd/cache_expire.c
   trunk/varnish-cache/bin/varnishd/cache_main.c
   trunk/varnish-cache/bin/varnishd/cache_pool.c
   trunk/varnish-cache/bin/varnishd/shmlog.c
Log:
Move the workerthreads log from malloc to stack.

Dump sizes of various structures on startup.



Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h	2007-10-01 07:27:37 UTC (rev 2071)
+++ trunk/varnish-cache/bin/varnishd/cache.h	2007-10-01 07:45:58 UTC (rev 2072)
@@ -176,9 +176,8 @@
 	struct srcaddr		*srcaddr;
 	struct acct		acct;
 
-	unsigned char		*wlp, *wle;
+	unsigned char		*wlb, *wlp, *wle;
 	unsigned		wlr;
-	unsigned char		wlog[WLOGSPACE];
 };
 
 struct workreq {

Modified: trunk/varnish-cache/bin/varnishd/cache_expire.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_expire.c	2007-10-01 07:27:37 UTC (rev 2071)
+++ trunk/varnish-cache/bin/varnishd/cache_expire.c	2007-10-01 07:45:58 UTC (rev 2072)
@@ -165,6 +165,7 @@
 	double t;
 	struct sess *sp;
 	struct object *o2;
+	unsigned char log[1024];		/* XXX size ? */
 
 	(void)arg;
 
@@ -172,8 +173,8 @@
 	XXXAN(sp);
 	sp->wrk = &ww;
 	ww.magic = WORKER_MAGIC;
-	ww.wlp = ww.wlog;
-	ww.wle = ww.wlog + sizeof ww.wlog;
+	ww.wlp = ww.wlb = log;
+	ww.wle = log + sizeof log;
 
 	AZ(sleep(10));		/* XXX: Takes time for VCL to arrive */
 	VCL_Get(&sp->vcl);

Modified: trunk/varnish-cache/bin/varnishd/cache_main.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_main.c	2007-10-01 07:27:37 UTC (rev 2071)
+++ trunk/varnish-cache/bin/varnishd/cache_main.c	2007-10-01 07:45:58 UTC (rev 2072)
@@ -51,6 +51,22 @@
 	setbuf(stderr, NULL);
 	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();
 	VCL_Init();
 

Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pool.c	2007-10-01 07:27:37 UTC (rev 2071)
+++ trunk/varnish-cache/bin/varnishd/cache_pool.c	2007-10-01 07:45:58 UTC (rev 2072)
@@ -202,13 +202,14 @@
 	struct worker w[1];
 	struct wq *qp;
 	char c;
+	unsigned char wlog[8192]; 	/* XXX: size */
 
 	qp = priv;
 	memset(w, 0, sizeof *w);
 	w->magic = WORKER_MAGIC;
 	w->used = TIM_real();
-	w->wlp = w->wlog;
-	w->wle = w->wlog + sizeof w->wlog;
+	w->wlb = w->wlp = wlog;
+	w->wle = wlog + sizeof wlog;
 	AZ(pipe(w->pipe));
 
 	VSL(SLT_WorkThread, 0, "%p start", w);

Modified: trunk/varnish-cache/bin/varnishd/shmlog.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/shmlog.c	2007-10-01 07:27:37 UTC (rev 2071)
+++ trunk/varnish-cache/bin/varnishd/shmlog.c	2007-10-01 07:45:58 UTC (rev 2072)
@@ -175,7 +175,7 @@
 	unsigned char *p;
 	unsigned l;
 
-	l = pdiff(w->wlog, w->wlp);
+	l = pdiff(w->wlb, w->wlp);
 	if (l == 0)
 		return;
 	LOCKSHM(&vsl_mtx);
@@ -184,14 +184,14 @@
 	if (loghead->ptr + l + 1 >= loghead->size)
 		vsl_wrap();
 	p = logstart + loghead->ptr;
-	memcpy(p + 1, w->wlog + 1, l - 1);
+	memcpy(p + 1, w->wlb + 1, l - 1);
 	p[l] = SLT_ENDMARKER;
 	loghead->ptr += l;
 	assert(loghead->ptr < loghead->size);
 	/* XXX: memory barrier here */
-	p[0] = w->wlog[0];
+	p[0] = w->wlb[0];
 	UNLOCKSHM(&vsl_mtx);
-	w->wlp = w->wlog;
+	w->wlp = w->wlb;
 	w->wlr = 0;
 }
 




More information about the varnish-commit mailing list