[master] 6a92b33 Add a session workspace for the TCP addresses etc.
Poul-Henning Kamp
phk at FreeBSD.org
Tue Dec 3 17:38:41 CET 2013
commit 6a92b339ffc5b084b1de410135dd9a054c97affe
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Dec 2 11:32:47 2013 +0000
Add a session workspace for the TCP addresses etc.
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 8983e18..d6e0526 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -766,6 +766,8 @@ struct sess {
/* Session related fields ------------------------------------*/
+ struct ws ws[1];
+
struct suckaddr *remote_addr;
struct suckaddr *local_addr;
diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c
index ad0f537..fb488af 100644
--- a/bin/varnishd/cache/cache_session.c
+++ b/bin/varnishd/cache/cache_session.c
@@ -51,8 +51,6 @@
#include "vtcp.h"
#include "vtim.h"
-static unsigned ses_size;
-
/*--------------------------------------------------------------------*/
struct sesspool {
@@ -94,34 +92,28 @@ SES_Charge(struct worker *wrk, struct req *req)
*
* Layout is:
* struct sess
- * struct vsa (local_addr)
- * struct vsa (remote_addr)
+ * workspace
*/
static struct sess *
ses_new(struct sesspool *pp)
{
struct sess *sp;
- char *s;
unsigned sz;
+ char *p, *e;
CHECK_OBJ_NOTNULL(pp, SESSPOOL_MAGIC);
sp = MPL_Get(pp->mpl_sess, &sz);
sp->magic = SESS_MAGIC;
sp->sesspool = pp;
- s = (char *)sp;
- s += sizeof *sp;
-
- memset(s, 0, vsa_suckaddr_len);
- sp->local_addr = (void*)s;
- s += vsa_suckaddr_len;
-
- memset(s, 0, vsa_suckaddr_len);
- sp->remote_addr = (void*)s;
- s += vsa_suckaddr_len;
-
- assert((char *)sp + sz == s);
+ e = (char*)sp + sz;
+ p = (char*)(sp + 1);
+ p = (void*)PRNDUP(p);
+ assert(p < e);
+ WS_Init(sp->ws, "sess", p, e - p);
+ sp->local_addr = (void*)WS_Alloc(sp->ws, vsa_suckaddr_len);
+ sp->remote_addr = (void*)WS_Alloc(sp->ws, vsa_suckaddr_len);
sp->t_open = NAN;
sp->t_idle = NAN;
@@ -454,8 +446,8 @@ SES_NewPool(struct pool *wp, unsigned pool_no)
pp->mpl_req = MPL_New(nb, &cache_param->req_pool,
&cache_param->workspace_client);
bprintf(nb, "sess%u", pool_no);
- ses_size = sizeof (struct sess) + vsa_suckaddr_len * 2L;
- pp->mpl_sess = MPL_New(nb, &cache_param->sess_pool, &ses_size);
+ pp->mpl_sess = MPL_New(nb, &cache_param->sess_pool,
+ &cache_param->workspace_session);
return (pp);
}
diff --git a/bin/varnishd/common/params.h b/bin/varnishd/common/params.h
index 8b075d2..58c7e9b 100644
--- a/bin/varnishd/common/params.h
+++ b/bin/varnishd/common/params.h
@@ -89,8 +89,9 @@ struct params {
unsigned wthread_queue_limit;
/* Memory allocation hints */
- unsigned workspace_client;
unsigned workspace_backend;
+ unsigned workspace_client;
+ unsigned workspace_session;
unsigned workspace_thread;
unsigned vsl_buffer;
diff --git a/bin/varnishd/mgt/mgt_param_tbl.c b/bin/varnishd/mgt/mgt_param_tbl.c
index 9d46259..d242efa 100644
--- a/bin/varnishd/mgt/mgt_param_tbl.c
+++ b/bin/varnishd/mgt/mgt_param_tbl.c
@@ -81,6 +81,13 @@ struct parspec mgt_parspec[] = {
"cache at the end of ttl+grace+keep.",
OBJ_STICKY,
"0", "seconds" },
+ { "workspace_session",
+ tweak_bytes_u, &mgt_param.workspace_session,
+ "256", NULL,
+ "Bytes of workspace for session and TCP connection addresses."
+ " If larger than 4k, use a multiple of 4k for VM efficiency.",
+ DELAYED_EFFECT,
+ "512", "bytes" },
{ "workspace_client",
tweak_bytes_u, &mgt_param.workspace_client,
"3072", NULL,
More information about the varnish-commit
mailing list