--------------------- PatchSet 817 Date: 2000/11/10 10:36:47 Author: hno Branch: hno-2_2-async Tag: (none) Log: Some more tuning Members: src/aiops.c:1.1.1.2.2.1.2.8->1.1.1.2.2.1.2.9 src/async_io.c:1.1.1.2.2.1.2.2->1.1.1.2.2.1.2.3 src/squid.h:1.1.1.2.2.1.2.4->1.1.1.2.2.1.2.5 Index: squid/src/aiops.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/aiops.c,v retrieving revision 1.1.1.2.2.1.2.8 retrieving revision 1.1.1.2.2.1.2.9 diff -u -r1.1.1.2.2.1.2.8 -r1.1.1.2.2.1.2.9 --- squid/src/aiops.c 9 Nov 2000 20:42:15 -0000 1.1.1.2.2.1.2.8 +++ squid/src/aiops.c 10 Nov 2000 10:36:47 -0000 1.1.1.2.2.1.2.9 @@ -1,5 +1,5 @@ /* - * $Id: aiops.c,v 1.1.1.2.2.1.2.8 2000/11/09 20:42:15 hno Exp $ + * $Id: aiops.c,v 1.1.1.2.2.1.2.9 2000/11/10 10:36:47 hno Exp $ * * DEBUG: section 43 AIOPS * AUTHOR: Stewart Forster @@ -835,7 +835,7 @@ high_start = squid_curtime; delta = squid_curtime - high_start; if ( (!agressive && load > MAGIC1 && delta > MAGIC1TIME) || - (load > MAGIC2 && delta > MAGIC2TIME) || + (load > MAGIC2 && (!agressive || delta > MAGIC2TIME)) || (load > MAGIC3)) { if (squid_curtime >= (last_warn + 10)) { debug(43, 0) ("Warning: Disk I/O overloaded (%d, %d)\n", load*100/MAGIC2, delta); Index: squid/src/async_io.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/async_io.c,v retrieving revision 1.1.1.2.2.1.2.2 retrieving revision 1.1.1.2.2.1.2.3 diff -u -r1.1.1.2.2.1.2.2 -r1.1.1.2.2.1.2.3 --- squid/src/async_io.c 9 Nov 2000 20:13:12 -0000 1.1.1.2.2.1.2.2 +++ squid/src/async_io.c 10 Nov 2000 10:36:47 -0000 1.1.1.2.2.1.2.3 @@ -1,6 +1,6 @@ /* - * $Id: async_io.c,v 1.1.1.2.2.1.2.2 2000/11/09 20:13:12 hno Exp $ + * $Id: async_io.c,v 1.1.1.2.2.1.2.3 2000/11/10 10:36:47 hno Exp $ * * DEBUG: section 32 Asynchronous Disk I/O * AUTHOR: Pete Bentley @@ -45,6 +45,8 @@ #define _AIO_OPENDIR 5 #define _AIO_STAT 6 +static dlink_list used_list; + typedef struct aio_ctrl_t { struct aio_ctrl_t *next; int fd; @@ -53,6 +55,7 @@ void *done_handler_data; aio_result_t result; void *tag; + dlink_node node; } aio_ctrl_t; struct { @@ -71,7 +74,6 @@ struct aio_unlinkq_t *next; } aio_unlinkq_t; -static aio_ctrl_t *used_list = NULL; static int initialised = 0; static OBJH aioStats; static MemPool *aio_ctrl_pool; @@ -117,8 +119,7 @@ ctrlp->operation = _AIO_OPEN; ctrlp->result.data = ctrlp; aio_open(path, oflag, mode, &ctrlp->result); - ctrlp->next = used_list; - used_list = ctrlp; + dlinkAdd(ctrlp, &ctrlp->node, &used_list); return; } @@ -137,8 +138,7 @@ ctrlp->operation = _AIO_CLOSE; ctrlp->result.data = ctrlp; aio_close(fd, &ctrlp->result); - ctrlp->next = used_list; - used_list = ctrlp; + dlinkAdd(ctrlp, &ctrlp->node, &used_list); return; } @@ -146,25 +146,23 @@ aioCancel(int fd, void *tag) { aio_ctrl_t *curr; - aio_ctrl_t *prev; - aio_ctrl_t *next; AIOCB *done_handler; void *their_data; + dlink_node *m, *next, *prev; assert(initialised); aio_counts.cancel++; prev = NULL; - curr = used_list; - for (curr = used_list;; curr = next) { - while (curr != NULL) { + for (m = used_list.head; m; m = next) { + while (m) { + curr = m->data; if (curr->fd == fd) break; if (tag != NULL && curr->tag == tag) break; - prev = curr; - curr = curr->next; + m = m->next; } - if (curr == NULL) + if (m == NULL) break; aio_cancel(&curr->result); @@ -176,12 +174,8 @@ debug(0, 0) ("this be aioCancel\n"); done_handler(fd, their_data, -2, -2); } - next = curr->next; - if (prev == NULL) - used_list = next; - else - prev->next = next; - + next = m->next; + dlinkDelete(m, &used_list); memPoolFree(aio_ctrl_pool, curr); } } @@ -208,8 +202,7 @@ } ctrlp->result.data = ctrlp; aio_write(fd, bufp, len, offset, seekmode, &ctrlp->result); - ctrlp->next = used_list; - used_list = ctrlp; + dlinkAdd(ctrlp, &ctrlp->node, &used_list); } /* aioWrite */ @@ -234,8 +227,7 @@ } ctrlp->result.data = ctrlp; aio_read(fd, bufp, len, offset, seekmode, &ctrlp->result); - ctrlp->next = used_list; - used_list = ctrlp; + dlinkAdd(ctrlp, &ctrlp->node, &used_list); return; } /* aioRead */ @@ -254,8 +246,7 @@ ctrlp->operation = _AIO_STAT; ctrlp->result.data = ctrlp; aio_stat(path, sb, &ctrlp->result); - ctrlp->next = used_list; - used_list = ctrlp; + dlinkAdd(ctrlp, &ctrlp->node, &used_list); return; } /* aioStat */ @@ -274,8 +265,7 @@ path = xstrdup(pathname); ctrlp->result.data = ctrlp; aio_unlink(path, &ctrlp->result); - ctrlp->next = used_list; - used_list = ctrlp; + dlinkAdd(ctrlp, &ctrlp->node, &used_list); xfree(path); } /* aioUnlink */ @@ -294,8 +284,7 @@ path = xstrdup(pathname); ctrlp->result.data = ctrlp; aio_truncate(path, length, &ctrlp->result); - ctrlp->next = used_list; - used_list = ctrlp; + dlinkAdd(ctrlp, &ctrlp->node, &used_list); xfree(path); } /* aioTruncate */ @@ -305,7 +294,6 @@ { aio_result_t *resultp; aio_ctrl_t *ctrlp; - aio_ctrl_t *prev; AIOCB *done_handler; void *their_data; @@ -314,20 +302,10 @@ for (;;) { if ((resultp = aio_poll_done()) == NULL) break; - prev = NULL; -#if 1 ctrlp = (aio_ctrl_t *)resultp->data; -#else - for (ctrlp = used_list; ctrlp != NULL; prev = ctrlp, ctrlp = ctrlp->next) - if (&ctrlp->result == resultp) - break; -#endif if (ctrlp == NULL) - continue; - if (prev == NULL) - used_list = ctrlp->next; - else - prev->next = ctrlp->next; + continue; /* Should not happen */ + dlinkDelete(&ctrlp->node, &used_list); if ((done_handler = ctrlp->done_handler)) { their_data = ctrlp->done_handler_data; ctrlp->done_handler = NULL; Index: squid/src/squid.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/squid.h,v retrieving revision 1.1.1.2.2.1.2.4 retrieving revision 1.1.1.2.2.1.2.5 diff -u -r1.1.1.2.2.1.2.4 -r1.1.1.2.2.1.2.5 --- squid/src/squid.h 9 Nov 2000 20:20:15 -0000 1.1.1.2.2.1.2.4 +++ squid/src/squid.h 10 Nov 2000 10:36:47 -0000 1.1.1.2.2.1.2.5 @@ -1,6 +1,6 @@ /* - * $Id: squid.h,v 1.1.1.2.2.1.2.4 2000/11/09 20:20:15 hno Exp $ + * $Id: squid.h,v 1.1.1.2.2.1.2.5 2000/11/10 10:36:47 hno Exp $ * * AUTHOR: Duane Wessels * @@ -403,11 +403,11 @@ #endif /* Where we start to defer new disk operations (swapout) (!agressive) */ -#define MAGIC1 (NUMTHREADS/2) +#define MAGIC1 (NUMTHREADS/3) #define MAGIC1TIME 2 /* Where we defer all new disk operations (swapin) */ #define MAGIC2 (MAGIC1*2) #define MAGIC2TIME 1 -/* Where we absolutely defer all new disk operations */ +/* Where we absolutely defer all new disk operations with no time filter */ #define MAGIC3 (MAGIC2*2)