From a03a656de39d0b053ebdfd28ad0662da163c2cf3 Mon Sep 17 00:00:00 2001 From: wessels <> Date: Thu, 6 Jul 2000 06:08:28 +0000 Subject: [PATCH] DW: - In storeDiskdSend() we used to loop on storeDiskdDirCallback(sd) if we were over the magic2 limit. There were two problems with that approach. The loop was at CPU speed; there were no delays. When this condition occurs, Squid could hog the CPU when it would be better to give some cycles to the diskd processes. Also, we need to check callbacks for *all* swap directories, not just the current one. This patch calls storeDirCallback() instead. It also adds an exponentially increasing delay between calls, with a 500ms limit. select is used as a somewhat portable microsecond sleep timer. --- src/fs/diskd/store_io_diskd.cc | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/fs/diskd/store_io_diskd.cc b/src/fs/diskd/store_io_diskd.cc index 5153ef83e1..4fd6eb0bb9 100644 --- a/src/fs/diskd/store_io_diskd.cc +++ b/src/fs/diskd/store_io_diskd.cc @@ -1,6 +1,6 @@ /* - * $Id: store_io_diskd.cc,v 1.12 2000/06/27 22:06:25 hno Exp $ + * $Id: store_io_diskd.cc,v 1.13 2000/07/06 00:08:28 wessels Exp $ * * DEBUG: section 81 Squid-side DISKD I/O functions. * AUTHOR: Duane Wessels @@ -468,8 +468,20 @@ storeDiskdSend(int mtype, SwapDir * sd, int id, storeIOState * sio, int size, in * then we can have a lot of messages in the queue (probably * up to 2*magic1) and we can run out of shared memory buffers. */ - while (diskdinfo->away > diskdinfo->magic2) - storeDiskdDirCallback(sd); + /* + * Note that we call storeDirCallback (for all SDs), rather + * than storeDiskdDirCallback for just this SD, so that while + * we're "blocking" on this SD we can also handle callbacks + * from other SDs that might be ready. + */ + while (diskdinfo->away > diskdinfo->magic2) { + struct timeval delay = + {0, 1}; + select(0, NULL, NULL, NULL, &delay); + storeDirCallback(); + if (delay.tv_usec < 1000000) + delay.tv_usec <<= 1; + } return x; } -- 2.47.3