[master] 9efa2b0 Introduce the obj_readonly parameter which disables obj.hits and obj.lastuse in order to not dirty VM pages containing cached objects.

Poul-Henning Kamp phk at varnish-cache.org
Thu May 10 11:56:52 CEST 2012


commit 9efa2b0005a9e9fbfee7ba47018ee64df679594f
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu May 10 09:56:07 2012 +0000

    Introduce the obj_readonly parameter which disables obj.hits and obj.lastuse
    in order to not dirty VM pages containing cached objects.

diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c
index 332211a..c028cb5 100644
--- a/bin/varnishd/cache/cache_center.c
+++ b/bin/varnishd/cache/cache_center.c
@@ -261,7 +261,8 @@ cnt_prepresp(struct sess *sp, struct worker *wrk, struct req *req)
 		    cache_param->lru_timeout &&
 		    EXP_Touch(req->obj->objcore))
 			req->obj->last_lru = req->t_resp;
-		req->obj->last_use = req->t_resp;	/* XXX: locking ? */
+		if (!cache_param->obj_readonly)
+			req->obj->last_use = req->t_resp; /* XXX: locking ? */
 	}
 	HTTP_Setup(req->resp, req->ws, req->vsl, HTTP_Resp);
 	RES_BuildHttp(sp);
diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index 1228126..6b84bab 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -398,7 +398,7 @@ HSH_Lookup(struct sess *sp)
 		assert(hash->deref(oh));
 		o = oc_getobj(&wrk->stats, oc);
 		CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
-		if (o->hits < INT_MAX)
+		if (!cache_param->obj_readonly && o->hits < INT_MAX)
 			o->hits++;
 		return (oc);
 	}
diff --git a/bin/varnishd/common/params.h b/bin/varnishd/common/params.h
index 6e502fd..1e13657 100644
--- a/bin/varnishd/common/params.h
+++ b/bin/varnishd/common/params.h
@@ -188,6 +188,8 @@ struct params {
 	unsigned		gzip_window;
 	unsigned		gzip_memlevel;
 
+	unsigned		obj_readonly;
+
 	double			critbit_cooloff;
 
 	double			shortlived;
diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c
index 885d2ce..c8f62bb 100644
--- a/bin/varnishd/mgt/mgt_param.c
+++ b/bin/varnishd/mgt/mgt_param.c
@@ -1260,6 +1260,12 @@ static const struct parspec input_parspec[] = {
 		0,
 		"10,100,10", ""},
 
+	{ "obj_readonly", tweak_bool, &mgt_param.obj_readonly, 0, 0,
+		"If set, we do not update obj.hits and obj.lastuse to"
+		"avoid dirtying VM pages associated with cached objects.",
+		0,
+		"false", ""},
+
 	{ NULL, NULL, NULL }
 };
 



More information about the varnish-commit mailing list