r3103 - trunk/varnish-cache/bin/varnishd
phk at projects.linpro.no
phk at projects.linpro.no
Tue Aug 19 09:46:42 CEST 2008
Author: phk
Date: 2008-08-19 09:46:40 +0200 (Tue, 19 Aug 2008)
New Revision: 3103
Modified:
trunk/varnish-cache/bin/varnishd/cache_backend_poll.c
Log:
Add exponential average of responsetime to output
Modified: trunk/varnish-cache/bin/varnishd/cache_backend_poll.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend_poll.c 2008-08-19 07:19:50 UTC (rev 3102)
+++ trunk/varnish-cache/bin/varnishd/cache_backend_poll.c 2008-08-19 07:46:40 UTC (rev 3103)
@@ -54,6 +54,9 @@
#include "vrt.h"
#include "cache_backend.h"
+/* Default averaging rate, we want something pretty responsive */
+#define AVG_RATE 4
+
struct vbp_target {
unsigned magic;
#define VBP_TARGET_MAGIC 0x6b7cb656
@@ -71,6 +74,10 @@
#include "cache_backend_poll.h"
#undef BITMAP
+ double last;
+ double avg;
+ double rate;
+
VTAILQ_ENTRY(vbp_target) list;
pthread_t thread;
};
@@ -205,6 +212,7 @@
TCP_close(&s);
t_now = TIM_real();
+ vt->last = t_now - t_start;
vt->good_recv |= 1;
/* XXX: Check reponse status */
vt->happy |= 1;
@@ -255,8 +263,16 @@
#define BITMAP(n, c, t, b) vt->n <<= 1;
#include "cache_backend_poll.h"
#undef BITMAP
+ vt->last = 0;
vbp_poke(vt);
+ /* Calculate exponential average */
+ if (vt->happy & 1) {
+ if (vt->rate < AVG_RATE)
+ vt->rate += 1.0;
+ vt->avg += (vt->last - vt->avg) / vt->rate;
+ }
+
i = 0;
#define BITMAP(n, c, t, b) bits[i++] = (vt->n & 1) ? c : '-';
#include "cache_backend_poll.h"
@@ -284,9 +300,10 @@
logmsg = "Still sick";
vt->backend->healthy = 0;
}
- VSL(SLT_Backend_health, 0, "%s %s %s %u %u %u",
+ VSL(SLT_Backend_health, 0, "%s %s %s %u %u %u %.6f %.6f",
vt->backend->vcl_name, logmsg, bits,
- vt->good, vt->probe.threshold, vt->probe.window);
+ vt->good, vt->probe.threshold, vt->probe.window,
+ vt->last, vt->avg);
if (!vt->stop)
dsleep(vt->probe.interval);
@@ -325,6 +342,7 @@
vt->backend->healthy ? "Healthy" : "Sick");
cli_out(cli, "Current states good: %2u threshold: %2u window: %2u\n",
vt->good, vt->probe.threshold, vt->probe.window);
+ cli_out(cli, "Average responsetime of good probes: %.6f\n", vt->avg);
cli_out(cli,
"Oldest "
" Newest\n");
More information about the varnish-commit
mailing list