--------------------- PatchSet 10665 Date: 2008/07/18 08:07:44 Author: adri Branch: delay_pool_write Tag: (none) Log: * Provide a hook to tell delay pools when an FD is actually being closed! * Create an array to track which class 5 pool an FD is in, if any * Use this hook to keep the class5 fd array in-sync * Then, use this array when determining which FDs to display in the debugging output, making it sensible again. This array should eventually be used to optimise the class 5 bucket updates so the whole fd array isn't being walked for each class 5 instance, but thats a further optimisation which can be done down the road. Members: src/delay_pools.c:1.21.4.7->1.21.4.8 src/fd.c:1.21->1.21.18.1 src/protos.h:1.170.2.4->1.170.2.5 Index: squid/src/delay_pools.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/delay_pools.c,v retrieving revision 1.21.4.7 retrieving revision 1.21.4.8 diff -u -r1.21.4.7 -r1.21.4.8 --- squid/src/delay_pools.c 18 Jul 2008 07:04:32 -0000 1.21.4.7 +++ squid/src/delay_pools.c 18 Jul 2008 08:07:44 -0000 1.21.4.8 @@ -1,6 +1,6 @@ /* - * $Id: delay_pools.c,v 1.21.4.7 2008/07/18 07:04:32 adri Exp $ + * $Id: delay_pools.c,v 1.21.4.8 2008/07/18 08:07:44 adri Exp $ * * DEBUG: section 77 Delay Pools * AUTHOR: David Luyer @@ -113,6 +113,13 @@ static delayPool *delay_data = NULL; static char *delay_no_delay; +/* + * This array is a hack. Explanation: + * + the entry is 0 for no pool, or the pool id starting from 1 (rather than 0 like elsehwere) + * + The entry is cleared on fd close + * + The entry is -overwritten- if the fd changes pool; its not closed/reopened! + */ +static char *delay_class_5_fds; static time_t delay_pools_last_update = 0; static hash_table *delay_id_ptr_hash = NULL; static long memory_used = 0; @@ -159,6 +166,7 @@ { delay_pools_last_update = getCurrentTime(); delay_no_delay = xcalloc(1, Squid_MaxFD); + delay_class_5_fds = xcalloc(1, Squid_MaxFD); cachemgrRegister("delay", "Delay Pool Levels", delayPoolStats, 0, 1); cachemgrRegister("delay2", "Delay Pool Statistics", delayPoolStatsNew, 0, 1); } @@ -337,6 +345,13 @@ return delay_no_delay[fd]; } +void +delayCloseFd(int fd) +{ + delay_no_delay[fd] = 0; /* XXX ? */ + delay_class_5_fds[fd] = 0; +} + static delay_id delayId(unsigned short pool, unsigned short position) { @@ -524,6 +539,7 @@ position = fd; delay_data[pool].class5->fds[position].aggregate = (int) (((double) Config.Delay.rates[pool]->individual.max_bytes * Config.Delay.initial) / 100); + delay_class_5_fds[fd] = pool + 1; return delayId(pool + 1, position); } @@ -1078,12 +1094,14 @@ delayPoolStatsAg(sentry, pool, type, rate, class5->aggregate, class5->aggregate_bytes); /* Per-FD stats! */ - /* XXX these are somewhat atm as there aren't any hooks to -clear- the delay class for a given fd on close! */ + /* delay_class_5_fds[] contains the pool id starting from 1, not from 0 */ for (i = 0; i < Biggest_FD; i++) { - if (type == 1) { - storeAppendPrintf(sentry, " FD: %d, aggregate %d\n", i, class5->fds[i].aggregate); - } else { - storeAppendPrintf(sentry, "pools.pool.%d.fd.%d.aggregate=%d\n", pool + 1, i, class5->fds[i].aggregate); + if (delay_class_5_fds[i] == (pool+1)) { + if (type == 1) { + storeAppendPrintf(sentry, " FD: %d, aggregate %d\n", i, class5->fds[i].aggregate); + } else { + storeAppendPrintf(sentry, "pools.pool.%d.fd.%d.aggregate=%d\n", pool + 1, i, class5->fds[i].aggregate); + } } } } Index: squid/src/fd.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/fd.c,v retrieving revision 1.21 retrieving revision 1.21.18.1 diff -u -r1.21 -r1.21.18.1 --- squid/src/fd.c 25 Jun 2007 14:51:46 -0000 1.21 +++ squid/src/fd.c 18 Jul 2008 08:07:44 -0000 1.21.18.1 @@ -1,6 +1,6 @@ /* - * $Id: fd.c,v 1.21 2007/06/25 14:51:46 squidadm Exp $ + * $Id: fd.c,v 1.21.18.1 2008/07/18 08:07:44 adri Exp $ * * DEBUG: section 51 Filedescriptor Functions * AUTHOR: Duane Wessels @@ -95,6 +95,7 @@ #if DELAY_POOLS if (F->slow_id) commRemoveSlow(fd); + delayCloseFd(fd); #endif fdUpdateBiggest(fd, 0); Number_FD--; Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/protos.h,v retrieving revision 1.170.2.4 retrieving revision 1.170.2.5 diff -u -r1.170.2.4 -r1.170.2.5 --- squid/src/protos.h 18 Jul 2008 07:04:33 -0000 1.170.2.4 +++ squid/src/protos.h 18 Jul 2008 08:07:44 -0000 1.170.2.5 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.170.2.4 2008/07/18 07:04:33 adri Exp $ + * $Id: protos.h,v 1.170.2.5 2008/07/18 08:07:44 adri Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -1330,6 +1330,7 @@ extern void delaySetNoDelay(int fd); extern void delayClearNoDelay(int fd); extern int delayIsNoDelay(int fd); +extern void delayCloseFd(int fd); extern delay_id delayClientRequest(clientHttpRequest *, acl_access **); extern delay_id delayClientReply(clientHttpRequest *, acl_access **); extern delay_id delayPoolClient(unsigned short pool, int fd, in_addr_t client);