[master] 4798d6910 Transit buffer: Add counters

Walid Boudebouda walid.boudebouda at gmail.com
Wed Jul 30 14:02:06 UTC 2025


commit 4798d6910c33ad0b0e52e1ec1dfb5cd4e2476cda
Author: Walid Boudebouda <walid.boudebouda at gmail.com>
Date:   Thu Jul 25 14:58:09 2024 +0200

    Transit buffer: Add counters
    
    This adds MAIN.transit_stored and MAIN.transit_buffered counters that allow
    to deffirentiate between the number of response body bytes that were stored
    and the ones that went through the transit buffer for uncacheable responses.

diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c
index 7e1625582..dfc7929a0 100644
--- a/bin/varnishd/cache/cache_obj.c
+++ b/bin/varnishd/cache/cache_obj.c
@@ -393,6 +393,11 @@ ObjExtend(struct worker *wrk, struct objcore *oc, ssize_t l, int final)
 		oc->boc->fetched_so_far += l;
 		obj_boc_notify(oc->boc);
 		Lck_Unlock(&oc->boc->mtx);
+
+		if (oc->boc->transit_buffer > 0)
+			wrk->stats->transit_buffered += l;
+		else if (oc->flags & OC_F_TRANSIENT)
+			wrk->stats->transit_stored += l;
 	}
 
 	assert(oc->boc->state < BOS_FINISHED);
diff --git a/bin/varnishtest/tests/c00111.vtc b/bin/varnishtest/tests/c00111.vtc
index 50ebd606d..52df80b67 100644
--- a/bin/varnishtest/tests/c00111.vtc
+++ b/bin/varnishtest/tests/c00111.vtc
@@ -17,6 +17,9 @@ client c1 {
 varnish v1 -vsl_catchup
 # with vai, this no longer fails systematically (which is good)
 varnish v1 -expect fetch_failed <= 1
+varnish v1 -expect transit_stored > 0
+varnish v1 -expect transit_stored <= 1850000
+varnish v1 -expect transit_buffered == 0
 
 varnish v1 -cliok "param.set transit_buffer 4k"
 
@@ -29,3 +32,5 @@ client c2 {
 varnish v1 -vsl_catchup
 varnish v1 -expect s_fetch == 2
 varnish v1 -expect fetch_failed <= 1
+varnish v1 -expect transit_stored <= 1850000
+varnish v1 -expect transit_buffered == 1850000
diff --git a/lib/libvsc/VSC_main.vsc b/lib/libvsc/VSC_main.vsc
index 22097f2d8..e0291c2f5 100644
--- a/lib/libvsc/VSC_main.vsc
+++ b/lib/libvsc/VSC_main.vsc
@@ -533,6 +533,26 @@
 
 	Total number of bytes forwarded to clients in pipe sessions
 
+.. varnish_vsc:: transit_stored
+	:format:	bytes
+	:group:		wrk
+	:oneliner:	Stored uncacheable body bytes
+
+	Total number of transient body bytes written to storage as if they
+	were reusable like a cacheable backend response. Transient objects
+	are stored for a single transaction, this includes uncacheable backend
+	responses, synthetic responses and client requests.
+
+.. varnish_vsc:: transit_buffered
+	:format:	bytes
+	:group:		wrk
+	:oneliner:	Buffered uncacheable response body bytes
+
+	Total number of uncacheable responses body bytes forwarded using a
+	fixed buffer allocated from storage. This behavior can be enabled by
+	the 'transit_buffer' parameter, or the 'beresp.transit_buffer' VCL
+	variable.
+
 .. varnish_vsc:: sess_closed
 	:group: wrk
 	:oneliner:	Session Closed


More information about the varnish-commit mailing list