[master] d46391faf Don't recache req->vcl in wrk unless it will speed things up later.
Poul-Henning Kamp
phk at FreeBSD.org
Tue Dec 11 11:51:11 UTC 2018
commit d46391fafb854fc9e6f0f217668de5e7f9311305
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue Dec 11 08:45:07 2018 +0000
Don't recache req->vcl in wrk unless it will speed things up later.
diff --git a/bin/varnishd/cache/cache_req.c b/bin/varnishd/cache/cache_req.c
index e0ade75a6..d16f550c4 100644
--- a/bin/varnishd/cache/cache_req.c
+++ b/bin/varnishd/cache/cache_req.c
@@ -217,12 +217,8 @@ Req_Cleanup(struct sess *sp, struct worker *wrk, struct req *req)
AZ(req->esi_level);
AZ(req->privs->magic);
- if (req->vcl != NULL) {
- if (wrk->vcl != NULL)
- VCL_Rel(&wrk->vcl);
- wrk->vcl = req->vcl;
- req->vcl = NULL;
- }
+ if (req->vcl != NULL)
+ VCL_Recache(wrk, &req->vcl);
/* Charge and log byte counters */
if (req->vsl->wid) {
diff --git a/bin/varnishd/cache/cache_varnishd.h b/bin/varnishd/cache/cache_varnishd.h
index ef3184bed..0c29891e6 100644
--- a/bin/varnishd/cache/cache_varnishd.h
+++ b/bin/varnishd/cache/cache_varnishd.h
@@ -382,6 +382,7 @@ void VCL_Panic(struct vsb *, const struct vcl *);
void VCL_Poll(void);
void VCL_Ref(struct vcl *);
void VCL_Refresh(struct vcl **);
+void VCL_Recache(struct worker *, struct vcl **);
void VCL_Rel(struct vcl **);
void VCL_TaskEnter(const struct vcl *, struct vrt_privs *);
void VCL_TaskLeave(const struct vcl *, struct vrt_privs *);
diff --git a/bin/varnishd/cache/cache_vrt_vcl.c b/bin/varnishd/cache/cache_vrt_vcl.c
index 5b443017c..051d16c9f 100644
--- a/bin/varnishd/cache/cache_vrt_vcl.c
+++ b/bin/varnishd/cache/cache_vrt_vcl.c
@@ -76,17 +76,36 @@ VCL_Method_Name(unsigned m)
void
VCL_Refresh(struct vcl **vcc)
{
+
+ while (vcl_active == NULL)
+ (void)usleep(100000);
+
if (*vcc == vcl_active)
return;
if (*vcc != NULL)
VCL_Rel(vcc); /* XXX: optimize locking */
- while (vcl_active == NULL)
- (void)usleep(100000);
-
vcl_get(vcc, NULL);
}
+void
+VCL_Recache(struct worker *wrk, struct vcl **vclp)
+{
+
+ AN(wrk);
+ AN(vclp);
+ CHECK_OBJ_NOTNULL(*vclp, VCL_MAGIC);
+
+ if (*vclp != vcl_active || wrk->vcl == vcl_active) {
+ VCL_Rel(vclp);
+ return;
+ }
+ if (wrk->vcl != NULL)
+ VCL_Rel(&wrk->vcl);
+ wrk->vcl = *vclp;
+ *vclp = NULL;
+}
+
void
VCL_Ref(struct vcl *vcl)
{
More information about the varnish-commit
mailing list