[master] 284758389 vsc: New MAIN.shm_bytes counters

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Fri Aug 5 09:16:05 UTC 2022


commit 284758389fed2fccf2e9dc719506fa80750594aa
Author: Darryl Rodden <darryl.rodden at varnish-software.com>
Date:   Tue Jul 5 14:40:48 2022 -0700

    vsc: New MAIN.shm_bytes counters
    
    We have various stat counters for the shared memory log (shmlog),
    but nothing to give us the number of bytes used (consumed). The
    new shm_bytes counter remedies that.
    
    Signed-off-by: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>

diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c
index 2e67bbd05..e43097ce7 100644
--- a/bin/varnishd/cache/cache_shmlog.c
+++ b/bin/varnishd/cache/cache_shmlog.c
@@ -193,6 +193,7 @@ vsl_get(unsigned len, unsigned records, unsigned flushes)
 	VSC_C_main->shm_writes++;
 	VSC_C_main->shm_flushes += flushes;
 	VSC_C_main->shm_records += records;
+	VSC_C_main->shm_bytes += VSL_BYTES(VSL_OVERHEAD + VSL_WORDS(len));
 
 	/* Wrap if necessary */
 	if (VSL_END(vsl_ptr, len) >= vsl_end)
diff --git a/bin/varnishtest/tests/l00006.vtc b/bin/varnishtest/tests/l00006.vtc
new file mode 100644
index 000000000..93fe5935a
--- /dev/null
+++ b/bin/varnishtest/tests/l00006.vtc
@@ -0,0 +1,18 @@
+varnishtest "Check shmlog stats"
+
+server s1 {
+    rxreq
+    txresp
+} -start
+
+varnish v1 -vcl+backend "" -start
+
+client c1 {
+    txreq
+    rxresp
+} -run
+
+varnish v1 -vsl_catchup
+varnish v1 -expect shm_writes > 0
+varnish v1 -expect shm_records > 0
+varnish v1 -expect shm_bytes > 0
diff --git a/lib/libvsc/VSC_main.vsc b/lib/libvsc/VSC_main.vsc
index 87bf4933b..c895f7a1c 100644
--- a/lib/libvsc/VSC_main.vsc
+++ b/lib/libvsc/VSC_main.vsc
@@ -703,6 +703,14 @@
 	of the shared memory log, cycling back to the beginning.
 
 
+.. varnish_vsc:: shm_bytes
+	:level:	diag
+	:format: bytes
+	:oneliner:	SHM bytes
+
+	Number of bytes written to the shared memory log.
+
+
 .. varnish_vsc:: backend_req
 	:oneliner:	Backend requests made
 


More information about the varnish-commit mailing list