[master] 36e2bfe7d Add per-filter accounting to VDP like we have it for VFP.
Poul-Henning Kamp
phk at FreeBSD.org
Tue Sep 29 13:58:07 UTC 2020
commit 36e2bfe7d34fdbf75ccf67a1263f8f7bac6c4788
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue Sep 29 13:53:10 2020 +0000
Add per-filter accounting to VDP like we have it for VFP.
The new VSL record is 'VdpAcct' and masked by default.
Fix the name of VDP_close() to VDP_Close() since I'm touching
all the lines anyway.
diff --git a/bin/varnishd/cache/cache_deliver_proc.c b/bin/varnishd/cache/cache_deliver_proc.c
index 85f92b4e3..ea186be28 100644
--- a/bin/varnishd/cache/cache_deliver_proc.c
+++ b/bin/varnishd/cache/cache_deliver_proc.c
@@ -83,6 +83,8 @@ VDP_bytes(struct req *req, enum vdp_action act, const void *ptr, ssize_t len)
/* Call the present layer, while pointing to the next layer down */
vdc->nxt = VTAILQ_NEXT(vdpe, list);
+ vdpe->calls++;
+ vdpe->bytes_in += len;
retval = vdpe->vdp->bytes(req, act, &vdpe->priv, ptr, len);
if (retval && (vdc->retval == 0 || retval < vdc->retval))
vdc->retval = retval; /* Latch error value */
@@ -131,16 +133,20 @@ VDP_Push(struct req *req, const struct vdp *vdp, void *priv)
return (vdc->retval);
}
-void
-VDP_close(struct req *req)
+uint64_t
+VDP_Close(struct req *req)
{
struct vdp_entry *vdpe;
struct vdp_ctx *vdc;
+ uint64_t rv = 0;
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
vdc = req->vdc;
while (!VTAILQ_EMPTY(&vdc->vdp)) {
vdpe = VTAILQ_FIRST(&vdc->vdp);
+ rv = vdpe->bytes_in;
+ VSLb(req->vsl, SLT_VdpAcct, "%s %ju %ju", vdpe->vdp->name,
+ (uintmax_t)vdpe->calls, (uintmax_t)rv);
if (vdc->retval >= 0)
AN(vdpe);
if (vdpe != NULL) {
@@ -152,6 +158,7 @@ VDP_close(struct req *req)
}
vdc->nxt = VTAILQ_FIRST(&vdc->vdp);
}
+ return (rv);
}
/*--------------------------------------------------------------------*/
diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c
index b22c61f60..9bd59b5c7 100644
--- a/bin/varnishd/cache/cache_esi_deliver.c
+++ b/bin/varnishd/cache/cache_esi_deliver.c
@@ -871,5 +871,5 @@ ved_deliver(struct req *req, struct boc *boc, int wantbody)
if (i && req->doclose == SC_NULL)
req->doclose = SC_REM_CLOSE;
- VDP_close(req);
+ (void)VDP_Close(req);
}
diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c
index 760cc04a3..d9fa10716 100644
--- a/bin/varnishd/cache/cache_fetch_proc.c
+++ b/bin/varnishd/cache/cache_fetch_proc.c
@@ -118,11 +118,11 @@ VFP_Setup(struct vfp_ctx *vc, struct worker *wrk)
* Returns the number of bytes processed by the lowest VFP in the stack
*/
-size_t
+uint64_t
VFP_Close(struct vfp_ctx *vc)
{
struct vfp_entry *vfe, *tmp;
- size_t rv = 0;
+ uint64_t rv = 0;
VTAILQ_FOREACH_SAFE(vfe, &vc->vfp, list, tmp) {
if (vfe->vfp->fini != NULL)
@@ -155,7 +155,7 @@ VFP_Open(struct vfp_ctx *vc)
if (vfe->closed != VFP_OK && vfe->closed != VFP_NULL) {
(void)VFP_Error(vc, "Fetch filter %s failed to open",
vfe->vfp->name);
- VFP_Close(vc);
+ (void)VFP_Close(vc);
return (-1);
}
}
diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h
index 9c3605a1b..483147196 100644
--- a/bin/varnishd/cache/cache_filter.h
+++ b/bin/varnishd/cache/cache_filter.h
@@ -128,6 +128,8 @@ struct vdp_entry {
const struct vdp *vdp;
void *priv;
VTAILQ_ENTRY(vdp_entry) list;
+ uint64_t calls;
+ uint64_t bytes_in;
};
VTAILQ_HEAD(vdp_entry_s, vdp_entry);
diff --git a/bin/varnishd/cache/cache_varnishd.h b/bin/varnishd/cache/cache_varnishd.h
index 16c4aaaaa..c365ce057 100644
--- a/bin/varnishd/cache/cache_varnishd.h
+++ b/bin/varnishd/cache/cache_varnishd.h
@@ -223,7 +223,7 @@ void CLI_Run(void);
void CLI_AddFuncs(struct cli_proto *p);
/* cache_deliver_proc.c */
-void VDP_close(struct req *req);
+uint64_t VDP_Close(struct req *req);
int VDP_DeliverObj(struct req *req);
extern const struct vdp VDP_gunzip;
@@ -251,7 +251,7 @@ enum vfp_status VFP_GetStorage(struct vfp_ctx *, ssize_t *sz, uint8_t **ptr);
void VFP_Extend(const struct vfp_ctx *, ssize_t sz);
void VFP_Setup(struct vfp_ctx *vc, struct worker *wrk);
int VFP_Open(struct vfp_ctx *bo);
-size_t VFP_Close(struct vfp_ctx *bo);
+uint64_t VFP_Close(struct vfp_ctx *bo);
extern const struct vfp VFP_gunzip;
extern const struct vfp VFP_gzip;
diff --git a/bin/varnishd/http1/cache_http1_deliver.c b/bin/varnishd/http1/cache_http1_deliver.c
index f5f2c9579..97c775dbf 100644
--- a/bin/varnishd/http1/cache_http1_deliver.c
+++ b/bin/varnishd/http1/cache_http1_deliver.c
@@ -169,5 +169,5 @@ V1D_Deliver(struct req *req, struct boc *boc, int sendbody)
sc = SC_REM_CLOSE;
if (sc != SC_NULL)
Req_Fail(req, sc);
- VDP_close(req);
+ (void)VDP_Close(req);
}
diff --git a/bin/varnishd/http2/cache_http2_deliver.c b/bin/varnishd/http2/cache_http2_deliver.c
index c2ef90eec..190356d5d 100644
--- a/bin/varnishd/http2/cache_http2_deliver.c
+++ b/bin/varnishd/http2/cache_http2_deliver.c
@@ -331,5 +331,5 @@ h2_deliver(struct req *req, struct boc *boc, int sendbody)
}
AZ(req->wrk->v1l);
- VDP_close(req);
+ (void)VDP_Close(req);
}
diff --git a/bin/varnishd/mgt/mgt_param_bits.c b/bin/varnishd/mgt/mgt_param_bits.c
index 61edab2e4..cc0812624 100644
--- a/bin/varnishd/mgt/mgt_param_bits.c
+++ b/bin/varnishd/mgt/mgt_param_bits.c
@@ -128,6 +128,7 @@ tweak_vsl_mask(struct vsb *vsb, const struct parspec *par, const char *arg)
(void)bit(mgt_param.vsl_mask, SLT_WorkThread, BSET);
(void)bit(mgt_param.vsl_mask, SLT_Hash, BSET);
(void)bit(mgt_param.vsl_mask, SLT_VfpAcct, BSET);
+ (void)bit(mgt_param.vsl_mask, SLT_VdpAcct, BSET);
(void)bit(mgt_param.vsl_mask, SLT_H2TxBody, BSET);
(void)bit(mgt_param.vsl_mask, SLT_H2TxHdr, BSET);
(void)bit(mgt_param.vsl_mask, SLT_H2RxBody, BSET);
diff --git a/include/tbl/vsl_tags.h b/include/tbl/vsl_tags.h
index ceb7ff917..49dd6ec95 100644
--- a/include/tbl/vsl_tags.h
+++ b/include/tbl/vsl_tags.h
@@ -696,6 +696,19 @@ SLTM(Notice, 0, "Informational messages about request handling",
"\n"
)
+SLTM(VdpAcct, 0, "Deliver filter accounting",
+ "Contains name of VDP and statistics.\n\n"
+ "The format is::\n\n"
+ "\t%s %d %d\n"
+ "\t| | |\n"
+ "\t| | +- Total bytes produced\n"
+ "\t| +---- Number of calls made\n"
+ "\t+------- Name of filter\n"
+ "\n"
+ NODEF_NOTICE
+)
+
+
#undef NOSUP_NOTICE
#undef NODEF_NOTICE
#undef SLTM
More information about the varnish-commit
mailing list