From a15d85ea6eaa37d32cfb8642f930726906c0e997 Mon Sep 17 00:00:00 2001 From: wessels <> Date: Thu, 16 May 2002 01:08:34 +0000 Subject: [PATCH] Two fixes from Steve Bennett s.bennett at lancaster.ac.uk 1) The running averager intAverage() approaches zero due to roundoff errors when the input values are less than the averaging interval, which is happening for redirector service times. For helper processes, we'll store the average service time in microseconds now. 2) the cachemgr output shows 'Time' as large numbers for idle helpers. This patch makes use of the 'answer_time' field and uses that for calculating service time in cachemgr stats output. --- src/helper.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/helper.cc b/src/helper.cc index c7c59d9cf7..a05d1bd01a 100644 --- a/src/helper.cc +++ b/src/helper.cc @@ -1,6 +1,6 @@ /* - * $Id: helper.cc,v 1.37 2002/05/15 10:30:27 hno Exp $ + * $Id: helper.cc,v 1.38 2002/05/15 19:08:34 wessels Exp $ * * DEBUG: section 29 Helper process maintenance * AUTHOR: Harvest Derived? @@ -410,8 +410,8 @@ helperStats(StoreEntry * sentry, helper * hlp) hlp->stats.replies); storeAppendPrintf(sentry, "queue length: %d\n", hlp->stats.queue_size); - storeAppendPrintf(sentry, "avg service time: %d msec\n", - hlp->stats.avg_svc_time); + storeAppendPrintf(sentry, "avg service time: %.2f msec\n", + (double) hlp->stats.avg_svc_time / 1000.0); storeAppendPrintf(sentry, "\n"); storeAppendPrintf(sentry, "%7s\t%7s\t%11s\t%s\t%7s\t%7s\t%7s\n", "#", @@ -423,7 +423,8 @@ helperStats(StoreEntry * sentry, helper * hlp) "Request"); for (link = hlp->servers.head; link; link = link->next) { srv = link->data; - tt = 0.001 * tvSubMsec(srv->dispatch_time, current_time); + tt = 0.001 * tvSubMsec(srv->dispatch_time, + srv->flags.busy ? current_time : srv->answer_time); storeAppendPrintf(sentry, "%7d\t%7d\t%11d\t%c%c%c%c\t%7.3f\t%7d\t%s\n", srv->index + 1, srv->rfd, @@ -731,9 +732,10 @@ helperHandleRead(int fd, void *data) helperRequestFree(r); srv->request = NULL; hlp->stats.replies++; + srv->answer_time = current_time; hlp->stats.avg_svc_time = intAverage(hlp->stats.avg_svc_time, - tvSubMsec(srv->dispatch_time, current_time), + tvSubUsec(srv->dispatch_time, current_time), hlp->stats.replies, REDIRECT_AV_FACTOR); if (srv->flags.shutdown) { comm_close(srv->wfd); -- 2.47.3