Re: hierarchy problems

From: Henrik Nordstrom <hno@dont-contact.us>
Date: Fri, 07 Jan 2000 04:52:42 +0100

Gergely Madarasz wrote:
> couldn't squid be told not to check for the fetches count since
> the beginning but for the last 5 minutes or something in the
> round-robin algorithm ?

Sure. Try the attached patch.

--
Henrik Nordstrom
Squid hacker

* squid-2.3.DEVEL3.round_robin_clear_counter.patch *

Fri Jan 7 04:48:25 CET 2000
Modified Files in squid/src
        cache_cf.c neighbors.c protos.h structs.h

Changed round-robin peer selection to reset it's counters every 5 minutes.
(it isn't really round-robin, more like least frequently used)

Index: squid/src/cache_cf.c
diff -u squid/src/cache_cf.c:1.1.1.35.2.3 squid/src/cache_cf.c:1.1.1.35.2.4
--- squid/src/cache_cf.c:1.1.1.35.2.3 Mon Nov 22 22:40:52 1999
+++ squid/src/cache_cf.c Fri Jan 7 04:48:22 2000
@@ -1017,6 +1017,7 @@
         head = &(*head)->next;
     *head = p;
     Config.npeers++;
+ peerClearRR(p);
 }
 
 static void
Index: squid/src/neighbors.c
diff -u squid/src/neighbors.c:1.1.1.37.2.4 squid/src/neighbors.c:1.1.1.37.2.5
--- squid/src/neighbors.c:1.1.1.37.2.4 Sat Oct 30 22:22:43 1999
+++ squid/src/neighbors.c Fri Jan 7 04:48:24 2000
@@ -288,6 +288,18 @@
     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)
 {
Index: squid/src/protos.h
diff -u squid/src/protos.h:1.1.1.45.2.4 squid/src/protos.h:1.1.1.45.2.5
--- squid/src/protos.h:1.1.1.45.2.4 Sun Nov 7 22:33:08 1999
+++ squid/src/protos.h Fri Jan 7 04:48:24 2000
@@ -628,6 +628,7 @@
 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);
Index: squid/src/structs.h
diff -u squid/src/structs.h:1.1.1.42.2.7 squid/src/structs.h:1.1.1.42.2.8
--- squid/src/structs.h:1.1.1.42.2.7 Wed Dec 22 00:02:23 1999
+++ squid/src/structs.h Fri Jan 7 04:48:25 2000
@@ -1102,6 +1102,7 @@
     struct in_addr addresses[10];
     int n_addresses;
     int rr_count;
+ int rr_lastcount;
     peer *next;
     int test_fd;
 #if USE_CARP
Received on Thu Jan 06 2000 - 21:45:55 MST

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:50:16 MST