[PATCH] Enhancement for gencache Systemtap script

Ralph Böhme slow at samba.org
Wed Jul 26 12:37:37 UTC 2017


Hi!

Attached is a patcht that adds gencache hits/misses stats to the gencache
systemtap script.

I'm adding a "negative cache hit" metric for the deletion markers in
gencache_notrans. Guess that makes sense in the way that it indicates we avoided
to look into the expensive txn based gencache.

Please review&push if happy.

-slow
-------------- next part --------------
From 701ec804f4159d29fcea7675f309bcaf8cf02246 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Wed, 26 Jul 2017 14:29:33 +0200
Subject: [PATCH] examples: add cache effectiveness stats to gencache.stp

Signed-off-by: Ralph Boehme <slow at samba.org>
---
 examples/systemtap/gencache.stp | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/examples/systemtap/gencache.stp b/examples/systemtap/gencache.stp
index 225f0ae..95fcff3 100755
--- a/examples/systemtap/gencache.stp
+++ b/examples/systemtap/gencache.stp
@@ -18,6 +18,7 @@
 #
 
 global running, intervals
+global cache_misses, cache_hits, neg_cache_hits
 
 probe begin {
 	printf("Collecting data, press ctrl-C to stop... ")
@@ -37,6 +38,18 @@ probe process(@1).library("*").function("gencache_parse").return {
 
 	duration = end - begin
 	intervals["gencache_parse"] <<< duration
+
+	if ($return == 0) {
+		cache_misses++
+	} else {
+		cache_hits++
+	}
+}
+
+probe process(@1).library("*").function("gencache_get_data_blob_parser") {
+	if ($timeout == 0) {
+		neg_cache_hits++
+	}
 }
 
 probe process(@1).library("*").function("gencache_get_data_blob") {
@@ -106,6 +119,16 @@ probe process(@1).library("*").function("gencache_stabilize").return {
 probe end {
 	printf("\n\n")
 
+	printf("Summary of cache access stats\n")
+	printf("=============================\n\n")
+	printf("%-10s %-10s %-10s\n",
+	       "Hits", "Misses", "Negative-Hits");
+	printf("--------------------------------------\n")
+	printf("%-10d %-10d %-10d\n",
+	       cache_hits, cache_misses, neg_cache_hits);
+
+	printf("\n")
+
 	foreach ([name] in intervals) {
 		printf("%-30s count: %d sum: %d us (min: %d us avg: %d us max: %d us)\n",
 		       name,
-- 
2.9.4



More information about the samba-technical mailing list