--------------------- PatchSet 10668 Date: 2008/07/18 18:15:09 Author: adri Branch: delay_pool_write Tag: (none) Log: Migrate delayPoolsUpdate() out into an event rather than in checkTimeouts(). This way it can be scheduled before the comm loop runs (like it does now) and it can be scheduled to run before the write slow fd callback. What was happening before was this: * write would drain fd, it'd be put on the slow queue * the rest of the second - no writes would occur * second would tick over - socket would wake up (eventRun() called before checkTimeouts()!) and try to write, find it can't, go back to sleep * then checkTimeouts() would run and the pools would be filled up This meant the slow write fds were being tickled every other second and thus the throughput is only half. Members: src/comm.c:1.60.2.4->1.60.2.5 src/comm_generic.c:1.12->1.12.2.1 src/delay_pools.c:1.21.4.9->1.21.4.10 Index: squid/src/comm.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/comm.c,v retrieving revision 1.60.2.4 retrieving revision 1.60.2.5 diff -u -r1.60.2.4 -r1.60.2.5 --- squid/src/comm.c 16 Jul 2008 12:38:33 -0000 1.60.2.4 +++ squid/src/comm.c 18 Jul 2008 18:15:09 -0000 1.60.2.5 @@ -1,6 +1,6 @@ /* - * $Id: comm.c,v 1.60.2.4 2008/07/16 12:38:33 adri Exp $ + * $Id: comm.c,v 1.60.2.5 2008/07/18 18:15:09 adri Exp $ * * DEBUG: section 5 Socket Functions * AUTHOR: Harvest Derived @@ -1189,8 +1189,9 @@ #if DELAY_POOLS slow_wfds = xcalloc(sizeof(int), Squid_MaxFD); slow_wfds_alt = xcalloc(sizeof(int), Squid_MaxFD); - /* High priority so it runs before other events */ - eventAdd("comm_slow_wfds_wakeup_event", comm_slow_wfds_wakeup_event, NULL, 1.0, 256); + /* High priority so it runs before other events but delay pools has to run at a higher prio! */ + /* So that way it gets a chance to add traffic to the buckets first! */ + eventAdd("comm_slow_wfds_wakeup_event", comm_slow_wfds_wakeup_event, NULL, 1.0, 128); #endif } @@ -1228,7 +1229,7 @@ for (j = 0; j < n; j++) { fd = slow_wfds_alt[j]; F = &fd_table[fd]; - debug(5, 5) ("wfds: pos %d - fd %d\n", j, fd); + debug(5, 1) ("wfds: waking up fd %d\n", fd); /* call the write callback attempt - this may requeue the FD for sleep */ F->rwstate.write_delayed = 0; /* let the write run now */ @@ -1269,6 +1270,7 @@ #if DELAY_POOLS if (state->delayid) { writesz = delayBytesWanted(state->delayid, 0, writesz); + debug(1, 1) ("commHandleWrite: FD %d: delay pool gave us %d bytes\n", fd, writesz); /* * If the bucket is empty then we push ourselves onto the slow write fds * list and worry about the write later. Index: squid/src/comm_generic.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/comm_generic.c,v retrieving revision 1.12 retrieving revision 1.12.2.1 diff -u -r1.12 -r1.12.2.1 --- squid/src/comm_generic.c 13 Jun 2008 01:52:49 -0000 1.12 +++ squid/src/comm_generic.c 18 Jul 2008 18:15:09 -0000 1.12.2.1 @@ -1,6 +1,6 @@ /* - * $Id: comm_generic.c,v 1.12 2008/06/13 01:52:49 squidadm Exp $ + * $Id: comm_generic.c,v 1.12.2.1 2008/07/18 18:15:09 adri Exp $ * * DEBUG: section 5 Socket Functions * @@ -314,9 +314,6 @@ int fd; fde *F = NULL; PF *callback; -#if DELAY_POOLS - delayPoolsUpdate(NULL); -#endif for (fd = 0; fd <= Biggest_FD; fd++) { F = &fd_table[fd]; if (!F->flags.open) Index: squid/src/delay_pools.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/delay_pools.c,v retrieving revision 1.21.4.9 retrieving revision 1.21.4.10 diff -u -r1.21.4.9 -r1.21.4.10 --- squid/src/delay_pools.c 18 Jul 2008 08:20:09 -0000 1.21.4.9 +++ squid/src/delay_pools.c 18 Jul 2008 18:15:09 -0000 1.21.4.10 @@ -1,6 +1,6 @@ /* - * $Id: delay_pools.c,v 1.21.4.9 2008/07/18 08:20:09 adri Exp $ + * $Id: delay_pools.c,v 1.21.4.10 2008/07/18 18:15:09 adri Exp $ * * DEBUG: section 77 Delay Pools * AUTHOR: David Luyer @@ -169,6 +169,7 @@ delay_class_5_fds = xcalloc(1, Squid_MaxFD); cachemgrRegister("delay", "Delay Pool Levels", delayPoolStats, 0, 1); cachemgrRegister("delay2", "Delay Pool Statistics", delayPoolStatsNew, 0, 1); + eventAdd("delayPoolsUpdate", delayPoolsUpdate, NULL, 1.0, 192); } void @@ -689,8 +690,7 @@ unsigned char class; if (!Config.Delay.pools) return; - if (incr < 1) - return; + eventAdd("delayPoolsUpdate", delayPoolsUpdate, NULL, 1.0, 192); delay_pools_last_update = squid_curtime; for (i = 0; i < Config.Delay.pools; i++) { class = Config.Delay.class[i];