From 82056f1ec5374cb2efa40f6b8c03e6f9323933c9 Mon Sep 17 00:00:00 2001 From: hno <> Date: Wed, 3 May 2000 02:31:44 +0000 Subject: [PATCH] hno squid-2.3.DEVEL3.round_robin_clear_counter.patch Squid-2.3.DEVEL3: Reset "round-robin" counters every 5 minutes Reset "round-robin" peer selection counters every 5 minutes to speed up recovery when a dead peer has come on line again ("round-robin" is implemented by "least-frequently-used", which without this patch gets stronly biased to the previously dead peer). --- ChangeLog | 2 ++ src/cache_cf.cc | 3 ++- src/neighbors.cc | 14 +++++++++++++- src/protos.h | 3 ++- src/structs.h | 3 ++- 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index b6826e001d..1006587e0c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -46,6 +46,8 @@ Changes to Squid-2.4.DEVEL3 (): by the origin server. Doing so could cause bandwidth spikes and/or negative hit ratio. - httpd_accel_single_host squid.conf directive + - "round-robin" cache_peer counters are reset every 5 minutes to + compensate previously dead peers Changes to Squid-2.4.DEVEL2 (): diff --git a/src/cache_cf.cc b/src/cache_cf.cc index bbae7e8ad2..5f7a4b9501 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -1,6 +1,6 @@ /* - * $Id: cache_cf.cc,v 1.339 2000/05/02 18:51:50 hno Exp $ + * $Id: cache_cf.cc,v 1.340 2000/05/02 20:31:44 hno Exp $ * * DEBUG: section 3 Configuration File Parsing * AUTHOR: Harvest Derived @@ -1037,6 +1037,7 @@ parse_peer(peer ** head) head = &(*head)->next; *head = p; Config.npeers++; + peerClearRR(p); } static void diff --git a/src/neighbors.cc b/src/neighbors.cc index 25e7a6a0ba..436623d329 100644 --- a/src/neighbors.cc +++ b/src/neighbors.cc @@ -1,6 +1,6 @@ /* - * $Id: neighbors.cc,v 1.281 2000/05/02 18:47:34 hno Exp $ + * $Id: neighbors.cc,v 1.282 2000/05/02 20:31:44 hno Exp $ * * DEBUG: section 15 Neighbor Routines * AUTHOR: Harvest Derived @@ -260,6 +260,18 @@ getRoundRobinParent(request_t * request) return q; } +/* This gets called every 5 minutes to clear the round-robin counter. */ +void +peerClearRR(void *data) +{ + peer *p = data; + p->rr_count -= p->rr_lastcount; + if (p->rr_count < 0) + p->rr_count = 0; + p->rr_lastcount = p->rr_count; + eventAdd("peerClearRR",peerClearRR, p, 5*60, 0); +} + peer * getDefaultParent(request_t * request) { diff --git a/src/protos.h b/src/protos.h index c65b25907b..f5446674fc 100644 --- a/src/protos.h +++ b/src/protos.h @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.360 2000/05/02 20:15:49 hno Exp $ + * $Id: protos.h,v 1.361 2000/05/02 20:31:45 hno Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -633,6 +633,7 @@ extern peer *peerFindByName(const char *); extern peer *peerFindByNameAndPort(const char *, unsigned short); extern peer *getDefaultParent(request_t * request); extern peer *getRoundRobinParent(request_t * request); +EVH peerClearRR; extern peer *getAnyParent(request_t * request); extern lookup_t peerDigestLookup(peer * p, request_t * request, StoreEntry * entry); extern peer *neighborsDigestSelect(request_t * request, StoreEntry * entry); diff --git a/src/structs.h b/src/structs.h index 214508a3ae..7e4d5bf549 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.322 2000/05/02 20:28:30 hno Exp $ + * $Id: structs.h,v 1.323 2000/05/02 20:31:45 hno Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -1117,6 +1117,7 @@ struct _peer { struct in_addr addresses[10]; int n_addresses; int rr_count; + int rr_lastcount; peer *next; int test_fd; #if USE_CARP -- 2.47.2