From: wessels <> Date: Sat, 14 Apr 2007 04:46:03 +0000 (+0000) Subject: Added 'service_times' cachemgr page to report service time percentiles X-Git-Tag: SQUID_3_0_PRE6~94 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=04a28d46f538763cbf06c16ffaf51826452c2f15;p=thirdparty%2Fsquid.git Added 'service_times' cachemgr page to report service time percentiles rather than just median values. --- diff --git a/src/StatHist.cc b/src/StatHist.cc index 75857df242..09c894780e 100644 --- a/src/StatHist.cc +++ b/src/StatHist.cc @@ -1,6 +1,6 @@ /* - * $Id: StatHist.cc,v 1.32 2005/09/03 12:33:32 serassio Exp $ + * $Id: StatHist.cc,v 1.33 2007/04/13 22:46:03 wessels Exp $ * * DEBUG: section 62 Generic Histogram * AUTHOR: Duane Wessels @@ -187,6 +187,12 @@ statHistVal(const StatHist * H, int bin) double statHistDeltaMedian(const StatHist * A, const StatHist * B) +{ + return statHistDeltaPctile(A, B, 0.5); +} + +double +statHistDeltaPctile(const StatHist * A, const StatHist * B, double pctile) { int i; int s1 = 0; @@ -208,7 +214,7 @@ statHistDeltaMedian(const StatHist * A, const StatHist * B) for (i = 0; i < A->capacity; i++) s1 += D[i]; - h = s1 >> 1; + h = int(s1 * pctile); for (i = 0; i < A->capacity; i++) { J = i; diff --git a/src/enums.h b/src/enums.h index e052646e3e..b468375312 100644 --- a/src/enums.h +++ b/src/enums.h @@ -1,6 +1,6 @@ /* - * $Id: enums.h,v 1.254 2006/08/21 00:50:41 robertc Exp $ + * $Id: enums.h,v 1.255 2007/04/13 22:46:03 wessels Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -470,14 +470,14 @@ typedef enum { enum { - MEDIAN_HTTP, - MEDIAN_ICP_QUERY, - MEDIAN_DNS, - MEDIAN_HIT, - MEDIAN_MISS, - MEDIAN_NM, - MEDIAN_NH, - MEDIAN_ICP_REPLY + PCTILE_HTTP, + PCTILE_ICP_QUERY, + PCTILE_DNS, + PCTILE_HIT, + PCTILE_MISS, + PCTILE_NM, + PCTILE_NH, + PCTILE_ICP_REPLY }; enum { diff --git a/src/protos.h b/src/protos.h index 769aa4b008..1b94dab66a 100644 --- a/src/protos.h +++ b/src/protos.h @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.537 2006/09/03 18:47:18 serassio Exp $ + * $Id: protos.h,v 1.538 2007/04/13 22:46:03 wessels Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -476,6 +476,7 @@ SQUIDCEXTERN void statHistCount(StatHist * H, double val); SQUIDCEXTERN void statHistCopy(StatHist * Dest, const StatHist * Orig); SQUIDCEXTERN void statHistSafeCopy(StatHist * Dest, const StatHist * Orig); SQUIDCEXTERN double statHistDeltaMedian(const StatHist * A, const StatHist * B); +SQUIDCEXTERN double statHistDeltaPctile(const StatHist * A, const StatHist * B, double pctile); SQUIDCEXTERN void statHistDump(const StatHist * H, StoreEntry * sentry, StatHistBinDumper * bd); SQUIDCEXTERN void statHistLogInit(StatHist * H, int capacity, double min, double max); SQUIDCEXTERN void statHistEnumInit(StatHist * H, int last_enum); diff --git a/src/stat.cc b/src/stat.cc index 7b80ce2b21..df5b24c85e 100644 --- a/src/stat.cc +++ b/src/stat.cc @@ -1,5 +1,5 @@ /* - * $Id: stat.cc,v 1.401 2007/04/12 18:16:24 wessels Exp $ + * $Id: stat.cc,v 1.402 2007/04/13 22:46:03 wessels Exp $ * * DEBUG: section 18 Cache Manager Statistics * AUTHOR: Harvest Derived @@ -85,7 +85,7 @@ static void statCountersInit(StatCounters *); static void statCountersInitSpecial(StatCounters *); static void statCountersClean(StatCounters *); static void statCountersCopy(StatCounters * dest, const StatCounters * orig); -static double statMedianSvc(int, int); +static double statPctileSvc(double, int, int); static void statStoreEntry(MemBuf * mb, StoreEntry * e); static double statCPUUsage(int minutes); static OBJH stat_io_get; @@ -561,32 +561,32 @@ info_get(StoreEntry * sentry) storeAppendPrintf(sentry, "Median Service Times (seconds) 5 min 60 min:\n"); storeAppendPrintf(sentry, "\tHTTP Requests (All): %8.5f %8.5f\n", - statMedianSvc(5, MEDIAN_HTTP) / 1000.0, - statMedianSvc(60, MEDIAN_HTTP) / 1000.0); + statPctileSvc(0.5, 5, PCTILE_HTTP) / 1000.0, + statPctileSvc(0.5, 60, PCTILE_HTTP) / 1000.0); storeAppendPrintf(sentry, "\tCache Misses: %8.5f %8.5f\n", - statMedianSvc(5, MEDIAN_MISS) / 1000.0, - statMedianSvc(60, MEDIAN_MISS) / 1000.0); + statPctileSvc(0.5, 5, PCTILE_MISS) / 1000.0, + statPctileSvc(0.5, 60, PCTILE_MISS) / 1000.0); storeAppendPrintf(sentry, "\tCache Hits: %8.5f %8.5f\n", - statMedianSvc(5, MEDIAN_HIT) / 1000.0, - statMedianSvc(60, MEDIAN_HIT) / 1000.0); + statPctileSvc(0.5, 5, PCTILE_HIT) / 1000.0, + statPctileSvc(0.5, 60, PCTILE_HIT) / 1000.0); storeAppendPrintf(sentry, "\tNear Hits: %8.5f %8.5f\n", - statMedianSvc(5, MEDIAN_NH) / 1000.0, - statMedianSvc(60, MEDIAN_NH) / 1000.0); + statPctileSvc(0.5, 5, PCTILE_NH) / 1000.0, + statPctileSvc(0.5, 60, PCTILE_NH) / 1000.0); storeAppendPrintf(sentry, "\tNot-Modified Replies: %8.5f %8.5f\n", - statMedianSvc(5, MEDIAN_NM) / 1000.0, - statMedianSvc(60, MEDIAN_NM) / 1000.0); + statPctileSvc(0.5, 5, PCTILE_NM) / 1000.0, + statPctileSvc(0.5, 60, PCTILE_NM) / 1000.0); storeAppendPrintf(sentry, "\tDNS Lookups: %8.5f %8.5f\n", - statMedianSvc(5, MEDIAN_DNS) / 1000.0, - statMedianSvc(60, MEDIAN_DNS) / 1000.0); + statPctileSvc(0.5, 5, PCTILE_DNS) / 1000.0, + statPctileSvc(0.5, 60, PCTILE_DNS) / 1000.0); storeAppendPrintf(sentry, "\tICP Queries: %8.5f %8.5f\n", - statMedianSvc(5, MEDIAN_ICP_QUERY) / 1000000.0, - statMedianSvc(60, MEDIAN_ICP_QUERY) / 1000000.0); + statPctileSvc(0.5, 5, PCTILE_ICP_QUERY) / 1000000.0, + statPctileSvc(0.5, 60, PCTILE_ICP_QUERY) / 1000000.0); squid_getrusage(&rusage); @@ -762,6 +762,55 @@ info_get(StoreEntry * sentry) #endif } +static void +service_times(StoreEntry * sentry) +{ + int p; + storeAppendPrintf(sentry, "Service Time Percentiles 5 min 60 min:\n"); + for (p = 5; p < 100; p += 5) { + storeAppendPrintf(sentry, "\tHTTP Requests (All): %2d%% %8.5f %8.5f\n", + p, + statPctileSvc((double) p / 100.0, 5, PCTILE_HTTP) / 1000.0, + statPctileSvc((double) p / 100.0, 60, PCTILE_HTTP) / 1000.0); + } + for (p = 5; p < 100; p += 5) { + storeAppendPrintf(sentry, "\tCache Misses: %2d%% %8.5f %8.5f\n", + p, + statPctileSvc((double) p / 100.0, 5, PCTILE_MISS) / 1000.0, + statPctileSvc((double) p / 100.0, 60, PCTILE_MISS) / 1000.0); + } + for (p = 5; p < 100; p += 5) { + storeAppendPrintf(sentry, "\tCache Hits: %2d%% %8.5f %8.5f\n", + p, + statPctileSvc((double) p / 100.0, 5, PCTILE_HIT) / 1000.0, + statPctileSvc((double) p / 100.0, 60, PCTILE_HIT) / 1000.0); + } + for (p = 5; p < 100; p += 5) { + storeAppendPrintf(sentry, "\tNear Hits: %2d%% %8.5f %8.5f\n", + p, + statPctileSvc((double) p / 100.0, 5, PCTILE_NH) / 1000.0, + statPctileSvc((double) p / 100.0, 60, PCTILE_NH) / 1000.0); + } + for (p = 5; p < 100; p += 5) { + storeAppendPrintf(sentry, "\tNot-Modified Replies: %2d%% %8.5f %8.5f\n", + p, + statPctileSvc((double) p / 100.0, 5, PCTILE_NM) / 1000.0, + statPctileSvc((double) p / 100.0, 60, PCTILE_NM) / 1000.0); + } + for (p = 5; p < 100; p += 5) { + storeAppendPrintf(sentry, "\tDNS Lookups: %2d%% %8.5f %8.5f\n", + p, + statPctileSvc((double) p / 100.0, 5, PCTILE_DNS) / 1000.0, + statPctileSvc((double) p / 100.0, 60, PCTILE_DNS) / 1000.0); + } + for (p = 5; p < 100; p += 5) { + storeAppendPrintf(sentry, "\tICP Queries: %2d%% %8.5f %8.5f\n", + p, + statPctileSvc((double) p / 100.0, 5, PCTILE_ICP_QUERY) / 1000000.0, + statPctileSvc((double) p / 100.0, 60, PCTILE_ICP_QUERY) / 1000000.0); + } +} + #define XAVG(X) (dt ? (double) (f->X - l->X) / dt : 0.0) static void statAvgDump(StoreEntry * sentry, int minutes, int hours) @@ -995,6 +1044,10 @@ statRegisterWithCacheManager(CacheManager & manager) "General Runtime Information", info_get, 0, 1); + manager.registerAction("service_times", + "Service Times (Percentiles)", + service_times, 0, 1); + manager.registerAction("filedescriptors", "Process Filedescriptor Allocation", fde::DumpStats, 0, 1); @@ -1091,7 +1144,7 @@ statAvgTick(void *notused) } if (Config.warnings.high_rptm > 0) { - int i = (int) statMedianSvc(20, MEDIAN_HTTP); + int i = (int) statPctileSvc(0.5, 20, PCTILE_HTTP); if (Config.warnings.high_rptm < i) debug(18, 0) ("WARNING: Median response time is %d milliseconds\n", i); @@ -1445,7 +1498,7 @@ statAvg60min(StoreEntry * e) } static double -statMedianSvc(int interval, int which) +statPctileSvc(double pctile, int interval, int which) { StatCounters *f; StatCounters *l; @@ -1465,54 +1518,42 @@ statMedianSvc(int interval, int which) switch (which) { - case MEDIAN_HTTP: - x = statHistDeltaMedian(&l->client_http.all_svc_time, &f->client_http.all_svc_time); + case PCTILE_HTTP: + x = statHistDeltaPctile(&l->client_http.all_svc_time, &f->client_http.all_svc_time, pctile); break; - case MEDIAN_HIT: - x = statHistDeltaMedian(&l->client_http.hit_svc_time, &f->client_http.hit_svc_time); + case PCTILE_HIT: + x = statHistDeltaPctile(&l->client_http.hit_svc_time, &f->client_http.hit_svc_time, pctile); break; - case MEDIAN_MISS: - x = statHistDeltaMedian(&l->client_http.miss_svc_time, &f->client_http.miss_svc_time); + case PCTILE_MISS: + x = statHistDeltaPctile(&l->client_http.miss_svc_time, &f->client_http.miss_svc_time, pctile); break; - case MEDIAN_NM: - x = statHistDeltaMedian(&l->client_http.nm_svc_time, &f->client_http.nm_svc_time); + case PCTILE_NM: + x = statHistDeltaPctile(&l->client_http.nm_svc_time, &f->client_http.nm_svc_time, pctile); break; - case MEDIAN_NH: - x = statHistDeltaMedian(&l->client_http.nh_svc_time, &f->client_http.nh_svc_time); + case PCTILE_NH: + x = statHistDeltaPctile(&l->client_http.nh_svc_time, &f->client_http.nh_svc_time, pctile); break; - case MEDIAN_ICP_QUERY: - x = statHistDeltaMedian(&l->icp.query_svc_time, &f->icp.query_svc_time); + case PCTILE_ICP_QUERY: + x = statHistDeltaPctile(&l->icp.query_svc_time, &f->icp.query_svc_time, pctile); break; - case MEDIAN_DNS: - x = statHistDeltaMedian(&l->dns.svc_time, &f->dns.svc_time); + case PCTILE_DNS: + x = statHistDeltaPctile(&l->dns.svc_time, &f->dns.svc_time, pctile); break; default: - debug(49, 5) ("get_median_val: unknown type.\n"); + debug(49, 5) ("statPctileSvc: unknown type.\n"); x = 0; } return x; } -/* - * SNMP wants ints, ick - */ -#if UNUSED_CODE -int -get_median_svc(int interval, int which) -{ - return (int) statMedianSvc(interval, which); -} - -#endif - StatCounters * snmpStatGet(int minutes) {