[master] 58687c6 Reduce the reporting in SLT_SessClose to be boolean bits.

Poul-Henning Kamp phk at FreeBSD.org
Tue Dec 3 17:38:41 CET 2013


commit 58687c69d6b893986ebe50551c11292b9699cba9
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Dec 2 13:20:21 2013 +0000

    Reduce the reporting in SLT_SessClose to be boolean bits.
    
    This saves approx 50 bytes of storage for the session structure
    and puts us comfortably below 256 bytes, at least i the IPv4 case.

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 9a6dc78..bf7fa0f 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -246,6 +246,12 @@ struct acct {
 #undef ACCT
 };
 
+struct acct_bit {
+#define ACCT(foo)	unsigned int	foo : 1;
+#include "tbl/acct_fields.h"
+#undef ACCT
+};
+
 /*--------------------------------------------------------------------*/
 
 #define L0(t, n)
@@ -775,7 +781,7 @@ struct sess {
 	char			*client_addr_str;
 	char			*client_port_str;
 
-	struct acct		acct_ses;
+	struct acct_bit		acct_bit;
 
 	/* Timestamps, all on TIM_real() timescale */
 	double			t_open;		/* fd accepted */
diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c
index 23a1feb..ae41fd1 100644
--- a/bin/varnishd/cache/cache_session.c
+++ b/bin/varnishd/cache/cache_session.c
@@ -81,7 +81,7 @@ SES_Charge(struct worker *wrk, struct req *req)
 
 #define ACCT(foo)				\
 	wrk->stats.s_##foo += a->foo;		\
-	sp->acct_ses.foo += a->foo;		\
+	if (a->foo) sp->acct_bit.foo =1;	\
 	a->foo = 0;
 #include "tbl/acct_fields.h"
 #undef ACCT
@@ -312,7 +312,7 @@ SES_Close(struct sess *sp, enum sess_close reason)
 void
 SES_Delete(struct sess *sp, enum sess_close reason, double now)
 {
-	struct acct *b;
+	struct acct_bit *b;
 	struct sesspool *pp;
 
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
@@ -328,8 +328,8 @@ SES_Delete(struct sess *sp, enum sess_close reason, double now)
 		now = VTIM_real();
 	assert(!isnan(sp->t_open));
 
-	b = &sp->acct_ses;
-	VSL(SLT_SessClose, sp->vxid, "%s %.3f %ju %ju %ju %ju %ju %ju",
+	b = &sp->acct_bit;
+	VSL(SLT_SessClose, sp->vxid, "%s %.3f %u %u %u %u %u %u",
 	    sess_close_2str(sp->reason, 0), now - sp->t_open, b->req,
 	    b->pipe, b->pass, b->fetch, b->hdrbytes, b->bodybytes);
 	VSL(SLT_End, sp->vxid, "%s", "");
diff --git a/bin/varnishd/mgt/mgt_param_tbl.c b/bin/varnishd/mgt/mgt_param_tbl.c
index d242efa..baae9ee 100644
--- a/bin/varnishd/mgt/mgt_param_tbl.c
+++ b/bin/varnishd/mgt/mgt_param_tbl.c
@@ -87,7 +87,7 @@ struct parspec mgt_parspec[] = {
 		"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" },
+		"256", "bytes" },
 	{ "workspace_client",
 		tweak_bytes_u, &mgt_param.workspace_client,
 		"3072", NULL,
diff --git a/include/tbl/vsl_tags.h b/include/tbl/vsl_tags.h
index 85b0343..b39028a 100644
--- a/include/tbl/vsl_tags.h
+++ b/include/tbl/vsl_tags.h
@@ -103,12 +103,12 @@ SLTM(SessClose, 0, "Client connection closed",
 	"The format is::\n\n"
 	"\t%s %f %u %u %u %u %u %u\n"
 	"\t|  |  |  |  |  |  |  |\n"
-	"\t|  |  |  |  |  |  |  +- Body bytes sent on session\n"
-	"\t|  |  |  |  |  |  +---- Header bytes sent on session\n"
-	"\t|  |  |  |  |  +------- Backend fetches by session\n"
-	"\t|  |  |  |  +---------- Requests handled with pass\n"
-	"\t|  |  |  +------------- If 'pipe' were used on session\n"
-	"\t|  |  +---------------- How many requests on session\n"
+	"\t|  |  |  |  |  |  |  +- Bool: Body bytes were sent\n"
+	"\t|  |  |  |  |  |  +---- Bool: Resp.Header bytes sent\n"
+	"\t|  |  |  |  |  +------- Bool: Backend fetches initiated\n"
+	"\t|  |  |  |  +---------- Bool: 'pass' used\n"
+	"\t|  |  |  +------------- Bool: 'pipe' used\n"
+	"\t|  |  +---------------- Bool: good requests completed\n"
 	"\t|  +------------------- How long the session was open\n"
 	"\t+---------------------- Why the connection closed\n"
 	"\n"



More information about the varnish-commit mailing list