r4303 - in branches/2.0/varnish-cache: bin/varnishd bin/varnishtest/tests include lib/libvcl
tfheen at projects.linpro.no
tfheen at projects.linpro.no
Thu Oct 8 15:58:25 CEST 2009
Author: tfheen
Date: 2009-10-08 15:58:25 +0200 (Thu, 08 Oct 2009)
New Revision: 4303
Modified:
branches/2.0/varnish-cache/bin/varnishd/cache_acceptor.c
branches/2.0/varnish-cache/bin/varnishd/cache_backend_poll.c
branches/2.0/varnish-cache/bin/varnishtest/tests/r00306.vtc
branches/2.0/varnish-cache/bin/varnishtest/tests/s00002.vtc
branches/2.0/varnish-cache/bin/varnishtest/tests/v00014.vtc
branches/2.0/varnish-cache/include/vrt.h
branches/2.0/varnish-cache/lib/libvcl/vcc_backend.c
branches/2.0/varnish-cache/lib/libvcl/vcc_fixed_token.c
Log:
Merge r4184, r4185: Add a ".initial" property to backend probe specifications.
r4184:
An explanatory comment.
r4185:
Add a ".initial" property to backend probe specifications.
This is the number of good probes we pretend to have already seen when
we start up, in order to speed up getting healthy backends.
The default value is one less than the .threshold, so the backend
will be set healthy if it manages to respond correctly to the very
first probe we send to it.
(A bit of this commit leaked in during r4184)
Modified: branches/2.0/varnish-cache/bin/varnishd/cache_acceptor.c
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/cache_acceptor.c 2009-10-08 13:34:03 UTC (rev 4302)
+++ branches/2.0/varnish-cache/bin/varnishd/cache_acceptor.c 2009-10-08 13:58:25 UTC (rev 4303)
@@ -68,6 +68,13 @@
pthread_t VCA_thread;
static struct timeval tv_sndtimeo;
static struct timeval tv_rcvtimeo;
+
+/*
+ * We want to get out of any kind of touble-hit TCP connections as fast
+ * as absolutely possible, so we set them LINGER enabled with zero timeout,
+ * so that even if there are outstanding write data on the socket, a close(2)
+ * will return immediately.
+ */
static const struct linger linger = {
.l_onoff = 1,
};
Modified: branches/2.0/varnish-cache/bin/varnishd/cache_backend_poll.c
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/cache_backend_poll.c 2009-10-08 13:34:03 UTC (rev 4302)
+++ branches/2.0/varnish-cache/bin/varnishd/cache_backend_poll.c 2009-10-08 13:58:25 UTC (rev 4303)
@@ -241,18 +241,82 @@
}
/*--------------------------------------------------------------------
- * One thread per backend to be poked.
+ * Record pokings...
*/
-static void *
-vbp_wrk_poll_backend(void *priv)
+static void
+vbp_start_poke(struct vbp_target *vt)
{
- struct vbp_target *vt;
+ CHECK_OBJ_NOTNULL(vt, VBP_TARGET_MAGIC);
+
+#define BITMAP(n, c, t, b) vt->n <<= 1;
+#include "cache_backend_poll.h"
+#undef BITMAP
+
+ vt->last = 0;
+ vt->resp_buf[0] = '\0';
+}
+
+static void
+vbp_has_poked(struct vbp_target *vt)
+{
unsigned i, j;
uint64_t u;
const char *logmsg;
char bits[10];
+ CHECK_OBJ_NOTNULL(vt, VBP_TARGET_MAGIC);
+
+ /* 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"
+#undef BITMAP
+ bits[i] = '\0';
+
+ u = vt->happy;
+ for (i = j = 0; i < vt->probe.window; i++) {
+ if (u & 1)
+ j++;
+ u >>= 1;
+ }
+ vt->good = j;
+
+ if (vt->good >= vt->probe.threshold) {
+ if (vt->backend->healthy)
+ logmsg = "Still healthy";
+ else
+ logmsg = "Back healthy";
+ vt->backend->healthy = 1;
+ } else {
+ if (vt->backend->healthy)
+ logmsg = "Went sick";
+ else
+ logmsg = "Still sick";
+ vt->backend->healthy = 0;
+ }
+ VSL(SLT_Backend_health, 0, "%s %s %s %u %u %u %.6f %.6f %s",
+ vt->backend->vcl_name, logmsg, bits,
+ vt->good, vt->probe.threshold, vt->probe.window,
+ vt->last, vt->avg, vt->resp_buf);
+}
+
+/*--------------------------------------------------------------------
+ * One thread per backend to be poked.
+ */
+
+static void *
+vbp_wrk_poll_backend(void *priv)
+{
+ struct vbp_target *vt;
+ unsigned u;
+
THR_SetName("backend poll");
CAST_OBJ_NOTNULL(vt, priv, VBP_TARGET_MAGIC);
@@ -272,59 +336,25 @@
if (vt->probe.threshold == 0)
vt->probe.threshold = 3;
+ if (vt->probe.threshold == ~0U)
+ vt->probe.initial = vt->probe.threshold - 1;
+
+ if (vt->probe.initial > vt->probe.threshold)
+ vt->probe.initial = vt->probe.threshold;
+
printf("Probe(\"%s\", %g, %g)\n",
- vt->req,
- vt->probe.timeout,
- vt->probe.interval);
+ vt->req, vt->probe.timeout, vt->probe.interval);
- /*lint -e{525} indent */
+ for (u = 0; u < vt->probe.initial; u++) {
+ vbp_start_poke(vt);
+ vt->happy |= 1;
+ vbp_has_poked(vt);
+ }
+
while (!vt->stop) {
-#define BITMAP(n, c, t, b) vt->n <<= 1;
-#include "cache_backend_poll.h"
-#undef BITMAP
- vt->last = 0;
- vt->resp_buf[0] = '\0';
+ vbp_start_poke(vt);
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"
-#undef BITMAP
- bits[i] = '\0';
-
- u = vt->happy;
- for (i = j = 0; i < vt->probe.window; i++) {
- if (u & 1)
- j++;
- u >>= 1;
- }
- vt->good = j;
-
- if (vt->good >= vt->probe.threshold) {
- if (vt->backend->healthy)
- logmsg = "Still healthy";
- else
- logmsg = "Back healthy";
- vt->backend->healthy = 1;
- } else {
- if (vt->backend->healthy)
- logmsg = "Went sick";
- else
- logmsg = "Still sick";
- vt->backend->healthy = 0;
- }
- VSL(SLT_Backend_health, 0, "%s %s %s %u %u %u %.6f %.6f %s",
- vt->backend->vcl_name, logmsg, bits,
- vt->good, vt->probe.threshold, vt->probe.window,
- vt->last, vt->avg, vt->resp_buf);
-
+ vbp_has_poked(vt);
if (!vt->stop)
TIM_sleep(vt->probe.interval);
}
Modified: branches/2.0/varnish-cache/bin/varnishtest/tests/r00306.vtc
===================================================================
--- branches/2.0/varnish-cache/bin/varnishtest/tests/r00306.vtc 2009-10-08 13:34:03 UTC (rev 4302)
+++ branches/2.0/varnish-cache/bin/varnishtest/tests/r00306.vtc 2009-10-08 13:58:25 UTC (rev 4303)
@@ -27,6 +27,7 @@
.host = "127.0.0.1"; .port = "9180";
.probe = {
.url = "/";
+ .initial = 0;
}
}
director foo random {
Modified: branches/2.0/varnish-cache/bin/varnishtest/tests/s00002.vtc
===================================================================
--- branches/2.0/varnish-cache/bin/varnishtest/tests/s00002.vtc 2009-10-08 13:34:03 UTC (rev 4302)
+++ branches/2.0/varnish-cache/bin/varnishtest/tests/s00002.vtc 2009-10-08 13:58:25 UTC (rev 4303)
@@ -18,6 +18,7 @@
.interval = 1s;
.window = 2;
.threshold = 1;
+ .initial = 0;
}
}
sub vcl_fetch {
Modified: branches/2.0/varnish-cache/bin/varnishtest/tests/v00014.vtc
===================================================================
--- branches/2.0/varnish-cache/bin/varnishtest/tests/v00014.vtc 2009-10-08 13:34:03 UTC (rev 4302)
+++ branches/2.0/varnish-cache/bin/varnishtest/tests/v00014.vtc 2009-10-08 13:58:25 UTC (rev 4303)
@@ -20,6 +20,7 @@
.interval = 1s;
.window = 3;
.threshold = 2;
+ .initial = 0;
}
}
Modified: branches/2.0/varnish-cache/include/vrt.h
===================================================================
--- branches/2.0/varnish-cache/include/vrt.h 2009-10-08 13:34:03 UTC (rev 4302)
+++ branches/2.0/varnish-cache/include/vrt.h 2009-10-08 13:58:25 UTC (rev 4303)
@@ -54,6 +54,7 @@
double interval;
unsigned window;
unsigned threshold;
+ unsigned initial;
};
/*
Modified: branches/2.0/varnish-cache/lib/libvcl/vcc_backend.c
===================================================================
--- branches/2.0/varnish-cache/lib/libvcl/vcc_backend.c 2009-10-08 13:34:03 UTC (rev 4302)
+++ branches/2.0/varnish-cache/lib/libvcl/vcc_backend.c 2009-10-08 13:58:25 UTC (rev 4303)
@@ -340,7 +340,8 @@
struct fld_spec *fs;
struct token *t_field;
struct token *t_did = NULL, *t_window = NULL, *t_threshold = NULL;
- unsigned window, threshold;
+ struct token *t_initial = NULL;
+ unsigned window, threshold, initial;
fs = vcc_FldSpec(tl,
"?url",
@@ -349,6 +350,7 @@
"?interval",
"?window",
"?threshold",
+ "?initial",
NULL);
ExpectErr(tl, '{');
@@ -356,6 +358,7 @@
window = 0;
threshold = 0;
+ initial = 0;
Fb(tl, 0, "\t.probe = {\n");
while (tl->t->tok != '}') {
@@ -396,6 +399,11 @@
window = vcc_UintVal(tl);
vcc_NextToken(tl);
ERRCHK(tl);
+ } else if (vcc_IdIs(t_field, "initial")) {
+ t_initial = tl->t;
+ initial = vcc_UintVal(tl);
+ vcc_NextToken(tl);
+ ERRCHK(tl);
} else if (vcc_IdIs(t_field, "threshold")) {
t_threshold = tl->t;
threshold = vcc_UintVal(tl);
@@ -441,8 +449,12 @@
vcc_ErrWhere(tl, t_window);
}
Fb(tl, 0, "\t\t.window = %u,\n", window);
- Fb(tl, 0, "\t\t.threshold = %u\n", threshold);
+ Fb(tl, 0, "\t\t.threshold = %u,\n", threshold);
}
+ if (t_initial != NULL)
+ Fb(tl, 0, "\t\t.initial = %u,\n", initial);
+ else
+ Fb(tl, 0, "\t\t.initial = ~0U,\n", initial);
Fb(tl, 0, "\t},\n");
ExpectErr(tl, '}');
vcc_NextToken(tl);
Modified: branches/2.0/varnish-cache/lib/libvcl/vcc_fixed_token.c
===================================================================
--- branches/2.0/varnish-cache/lib/libvcl/vcc_fixed_token.c 2009-10-08 13:34:03 UTC (rev 4302)
+++ branches/2.0/varnish-cache/lib/libvcl/vcc_fixed_token.c 2009-10-08 13:58:25 UTC (rev 4303)
@@ -247,12 +247,12 @@
vsb_cat(sb, "\nstruct vrt_backend_probe {\n\tconst char\t*url;\n");
vsb_cat(sb, "\tconst char\t*request;\n\tdouble\t\ttimeout;\n");
vsb_cat(sb, "\tdouble\t\tinterval;\n\tunsigned\twindow;\n");
- vsb_cat(sb, "\tunsigned\tthreshold;\n};\n\n/*\n");
- vsb_cat(sb, " * A backend is a host+port somewhere on the network\n");
- vsb_cat(sb, " */\nstruct vrt_backend {\n\tconst char\t\t\t*vcl_name");
- vsb_cat(sb, ";\n\tconst char\t\t\t*ident;\n\n");
- vsb_cat(sb, "\tconst char\t\t\t*hosthdr;\n\n");
- vsb_cat(sb, "\tconst unsigned char\t\t*ipv4_sockaddr;\n");
+ vsb_cat(sb, "\tunsigned\tthreshold;\n\tunsigned\tinitial;\n");
+ vsb_cat(sb, "};\n\n/*\n * A backend is a host+port somewhere on the");
+ vsb_cat(sb, " network\n */\nstruct vrt_backend {\n");
+ vsb_cat(sb, "\tconst char\t\t\t*vcl_name;\n\tconst char\t\t\t*ident");
+ vsb_cat(sb, ";\n\n\tconst char\t\t\t*hosthdr;\n");
+ vsb_cat(sb, "\n\tconst unsigned char\t\t*ipv4_sockaddr;\n");
vsb_cat(sb, "\tconst unsigned char\t\t*ipv6_sockaddr;\n");
vsb_cat(sb, "\n\tdouble\t\t\t\tconnect_timeout;\n");
vsb_cat(sb, "\tdouble\t\t\t\tfirst_byte_timeout;\n");
@@ -324,9 +324,9 @@
/* ../../include/vrt_obj.h */
- vsb_cat(sb, "/*\n * $Id$\n");
- vsb_cat(sb, " *\n * NB: This file is machine generated, DO NOT EDI");
- vsb_cat(sb, "T!\n *\n * Edit vcc_gen_obj.tcl instead\n");
+ vsb_cat(sb, "/*\n * $Id: vcc_gen_obj.tcl 4082 2009-05-19 07:14:00Z ");
+ vsb_cat(sb, "sky $\n *\n * NB: This file is machine generated, DO ");
+ vsb_cat(sb, "NOT EDIT!\n *\n * Edit vcc_gen_obj.tcl instead\n");
vsb_cat(sb, " */\n\nstruct sockaddr * VRT_r_client_ip(const struct ");
vsb_cat(sb, "sess *);\nstruct sockaddr * VRT_r_server_ip(struct ses");
vsb_cat(sb, "s *);\nconst char * VRT_r_server_hostname(struct sess ");
More information about the varnish-commit
mailing list