From a4ba1105a7e787cd2bd79649bc613d4a986ad1c6 Mon Sep 17 00:00:00 2001 From: hno <> Date: Sat, 18 Jan 2003 09:10:37 +0000 Subject: [PATCH] date: 2003/01/10 17:52:53; author: wessels; state: Exp; lines: +1 -0 added reporting of "Process Data Segment Size via sbrk()" when sbrk() call exists. According to the sbrk() man page, calling sbrk(0) returns the end of the data segment. By storing the data segment offset when Squid starts, we can report the size of the data segment at any time. This might be a better metric than getrusage()'s MAX RSS, which, in my experience, is often less than the process size reported by 'ps' (presumably because some of the processes memory is swapped to disk). However, initial tests show that the sbrk() trick reports a value slightly smaller than reported by 'ps'. date: 2003/01/17 05:21:49; author: wessels; state: Exp; lines: +1 -1 failure_ratio is a ratio, not a percentage. Removed %% from printf. --- configure.in | 5 +++-- include/autoconf.h.in | 3 +++ src/globals.h | 5 ++++- src/main.cc | 6 +++++- src/stat.cc | 8 ++++++-- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/configure.in b/configure.in index b720c747a5..5d3136b6a5 100644 --- a/configure.in +++ b/configure.in @@ -3,7 +3,7 @@ dnl Configuration input file for Squid dnl dnl Duane Wessels, wessels@nlanr.net, February 1996 (autoconf v2.9) dnl -dnl $Id: configure.in,v 1.311 2003/01/17 03:54:36 robertc Exp $ +dnl $Id: configure.in,v 1.312 2003/01/18 02:10:37 hno Exp $ dnl dnl dnl @@ -13,7 +13,7 @@ AC_CONFIG_SRCDIR([src/main.cc]) AC_CONFIG_AUX_DIR(cfgaux) AM_INIT_AUTOMAKE(squid, 3.0-DEVEL) AM_CONFIG_HEADER(include/autoconf.h) -AC_REVISION($Revision: 1.311 $)dnl +AC_REVISION($Revision: 1.312 $)dnl AC_PREFIX_DEFAULT(/usr/local/squid) AM_MAINTAINER_MODE @@ -1804,6 +1804,7 @@ AC_CHECK_FUNCS(\ regfree \ res_init \ rint \ + sbrk \ select \ seteuid \ setgroups \ diff --git a/include/autoconf.h.in b/include/autoconf.h.in index de4d4b9f5e..6e0c1d6fe3 100644 --- a/include/autoconf.h.in +++ b/include/autoconf.h.in @@ -386,6 +386,9 @@ /* Define to 1 if you have the `rint' function. */ #undef HAVE_RINT +/* Define to 1 if you have the `sbrk' function. */ +#undef HAVE_SBRK + /* Define to 1 if you have the header file. */ #undef HAVE_SCHED_H diff --git a/src/globals.h b/src/globals.h index 9b0467afc0..73f5b2cc98 100644 --- a/src/globals.h +++ b/src/globals.h @@ -1,6 +1,6 @@ /* - * $Id: globals.h,v 1.116 2003/01/17 05:14:29 robertc Exp $ + * $Id: globals.h,v 1.117 2003/01/18 02:10:40 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -159,6 +159,9 @@ extern int incoming_sockets_accepted; extern unsigned int WIN32_OS_version; /* 0 */ extern char *WIN32_OS_string; /* NULL */ #endif +#if HAVE_SBRK +extern void *sbrk_start; /* 0 */ +#endif extern int ssl_ex_index_server; /* -1 */ extern int ssl_ctx_ex_index_dont_verify_domain; /* -1 */ diff --git a/src/main.cc b/src/main.cc index a8f1f1030e..ff2ab97a54 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,6 +1,6 @@ /* - * $Id: main.cc,v 1.360 2003/01/02 08:44:17 robertc Exp $ + * $Id: main.cc,v 1.361 2003/01/18 02:10:40 hno Exp $ * * DEBUG: section 1 Startup and Main Loop * AUTHOR: Harvest Derived @@ -568,6 +568,10 @@ main(int argc, char **argv) int WIN32_init_err; #endif +#if HAVE_SBRK + sbrk_start = sbrk(0); +#endif + debug_log = stderr; if (FD_SETSIZE < Squid_MaxFD) Squid_MaxFD = FD_SETSIZE; diff --git a/src/stat.cc b/src/stat.cc index 975113bb60..797110cd00 100644 --- a/src/stat.cc +++ b/src/stat.cc @@ -1,6 +1,6 @@ /* - * $Id: stat.cc,v 1.364 2002/12/27 10:26:33 robertc Exp $ + * $Id: stat.cc,v 1.365 2003/01/18 02:10:40 hno Exp $ * * DEBUG: section 18 Cache Manager Statistics * AUTHOR: Harvest Derived @@ -457,7 +457,7 @@ info_get(StoreEntry * sentry) statCounter.icp.pkts_sent); storeAppendPrintf(sentry, "\tNumber of queued ICP replies:\t%u\n", statCounter.icp.replies_queued); - storeAppendPrintf(sentry, "\tRequest failure ratio:\t%5.2f%%\n", + storeAppendPrintf(sentry, "\tRequest failure ratio:\t%5.2f\n", request_failure_ratio); storeAppendPrintf(sentry, "\tAverage HTTP requests per minute since start:\t%.1f\n", @@ -524,6 +524,10 @@ info_get(StoreEntry * sentry) statCPUUsage(5)); storeAppendPrintf(sentry, "\tCPU Usage, 60 minute avg:\t%.2f%%\n", statCPUUsage(60)); +#if HAVE_SBRK + storeAppendPrintf(sentry, "\tProcess Data Segment Size via sbrk(): %d KB\n", + (sbrk(0) - sbrk_start) >> 10); +#endif storeAppendPrintf(sentry, "\tMaximum Resident Size: %d KB\n", rusage_maxrss(&rusage)); storeAppendPrintf(sentry, "\tPage faults with physical i/o: %d\n", -- 2.47.3