r3874 - trunk/varnish-cache/bin/varnishd
phk at projects.linpro.no
phk at projects.linpro.no
Wed Mar 4 11:55:28 CET 2009
Author: phk
Date: 2009-03-04 11:55:28 +0100 (Wed, 04 Mar 2009)
New Revision: 3874
Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_pool.c
Log:
Begin moving bereq into the worker thread.
The original expectation was a ratio of 1:10 bereq:worker but once again
reality lets down data-less speculation.
It might have been true in a scenario where the majority of objects
bind the worker thread for significant time during delivery (ie:
ISOs over 28.8 modems) but that is not what happens in reality.
With objects rapidly delivered, backend contacts will size the worker
thread pool, since that is where they spend their time "out of the loop",
and consequenty, ratios of bereq/worker is much close to 1:1 than 1:10.
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2009-03-04 09:40:06 UTC (rev 3873)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2009-03-04 10:55:28 UTC (rev 3874)
@@ -217,6 +217,9 @@
unsigned wlr;
struct SHA256Context *sha256ctx;
+
+ struct ws ws[1];
+ struct http http[3];
};
/* Work Request for worker thread ------------------------------------*/
Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pool.c 2009-03-04 09:40:06 UTC (rev 3873)
+++ trunk/varnish-cache/bin/varnishd/cache_pool.c 2009-03-04 10:55:28 UTC (rev 3874)
@@ -291,18 +291,17 @@
/*--------------------------------------------------------------------*/
static void *
-wrk_thread(void *priv)
+wrk_thread_real(struct wq *qp, unsigned shm_workspace, unsigned sess_workspace)
{
struct worker *w, ww;
- struct wq *qp;
- unsigned char wlog[params->shm_workspace];
+ unsigned char wlog[shm_workspace];
+ unsigned char ws[sess_workspace];
struct SHA256Context sha256;
struct dstat stats;
unsigned stats_clean = 0;
THR_SetName("cache-worker");
w = &ww;
- CAST_OBJ_NOTNULL(qp, priv, WQ_MAGIC);
memset(w, 0, sizeof *w);
memset(&stats, 0, sizeof stats);
w->magic = WORKER_MAGIC;
@@ -313,6 +312,8 @@
w->sha256ctx = &sha256;
AZ(pthread_cond_init(&w->cond, NULL));
+ WS_Init(w->ws, "wrk", ws, sess_workspace);
+
VSL(SLT_WorkThread, 0, "%p start", w);
Lck_Lock(&qp->mtx);
@@ -342,6 +343,10 @@
AN(w->wrq->func);
w->lastused = NAN;
stats_clean = 0;
+ WS_Reset(w->ws, NULL);
+ http_Setup(&w->http[0], w->ws);
+ http_Setup(&w->http[1], w->ws);
+ http_Setup(&w->http[2], w->ws);
w->wrq->func(w, w->wrq->priv);
AZ(w->wfd);
assert(w->wlp == w->wlb);
@@ -368,6 +373,18 @@
return (NULL);
}
+static void *
+wrk_thread(void *priv)
+{
+ struct wq *qp;
+
+ CAST_OBJ_NOTNULL(qp, priv, WQ_MAGIC);
+ /* We need to snapshot these two for consistency */
+ return (wrk_thread_real(qp,
+ params->shm_workspace,
+ params->sess_workspace));
+}
+
/*--------------------------------------------------------------------
* Queue a workrequest if possible.
*
More information about the varnish-commit
mailing list