From: amosjeffries <> Date: Mon, 25 Feb 2008 09:45:50 +0000 (+0000) Subject: Author: hno X-Git-Tag: SQUID_3_0_STABLE2~44 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ba9bd8048460c13960d640475769cf1b17c0946f;p=thirdparty%2Fsquid.git Author: hno Bug #2114: cache memory accounting not working well Use the page allocator statistics to report cache_mem usage This patch removes the weak attempt in keeping an byte-exact cache_mem usage counter, instead using the actual allocated size (but excluding overhead). This is the same accounting method as used in Squid-2 btw.. --- diff --git a/src/mem_node.cc b/src/mem_node.cc index dc44b48978..d68e220383 100644 --- a/src/mem_node.cc +++ b/src/mem_node.cc @@ -1,6 +1,6 @@ /* - * $Id: mem_node.cc,v 1.10 2007/08/13 17:20:51 hno Exp $ + * $Id: mem_node.cc,v 1.10.2.1 2008/02/25 02:45:50 amosjeffries Exp $ * * DEBUG: section 19 Store Memory Primitives * AUTHOR: Robert Collins @@ -38,7 +38,6 @@ static int makeMemNodeDataOffset(); -unsigned long mem_node::store_mem_size; static int _mem_node_data_offset = makeMemNodeDataOffset(); /* @@ -70,9 +69,7 @@ mem_node::mem_node(int64_t offset):nodeBuffer(0,offset,data) {} mem_node::~mem_node() -{ - store_mem_size -= nodeBuffer.length; -} +{} size_t mem_node::InUseCount() @@ -80,6 +77,12 @@ mem_node::InUseCount() return Pool().inUseCount(); } +size_t +mem_node::StoreMemSize() +{ + return InUseCount() * SM_PAGE_SIZE; +} + int64_t mem_node::start() const { diff --git a/src/mem_node.h b/src/mem_node.h index 15a20c98e9..28a36f16ab 100644 --- a/src/mem_node.h +++ b/src/mem_node.h @@ -1,6 +1,6 @@ /* - * $Id: mem_node.h,v 1.10 2007/08/13 17:20:51 hno Exp $ + * $Id: mem_node.h,v 1.10.2.1 2008/02/25 02:45:50 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -42,7 +42,7 @@ class mem_node public: static size_t InUseCount(); - static unsigned long store_mem_size; /* 0 */ + static size_t StoreMemSize(); MEMPROXY_CLASS(mem_node); mem_node(int64_t); diff --git a/src/snmp_agent.cc b/src/snmp_agent.cc index d57bc55e81..8577550408 100644 --- a/src/snmp_agent.cc +++ b/src/snmp_agent.cc @@ -1,6 +1,6 @@ /* - * $Id: snmp_agent.cc,v 1.96 2007/04/28 22:26:37 hno Exp $ + * $Id: snmp_agent.cc,v 1.96.4.1 2008/02/25 02:45:50 amosjeffries Exp $ * * DEBUG: section 49 SNMP Interface * AUTHOR: Kostas Anagnostakis @@ -57,7 +57,7 @@ snmp_sysFn(variable_list * Var, snint * ErrP) case SYSVMSIZ: Answer = snmp_var_new_integer(Var->name, Var->name_length, - mem_node::store_mem_size >> 10, + mem_node::StoreMemSize() >> 10, ASN_INTEGER); break; diff --git a/src/stat.cc b/src/stat.cc index 7a13dfcc94..b234aa9d4e 100644 --- a/src/stat.cc +++ b/src/stat.cc @@ -1,5 +1,5 @@ /* - * $Id: stat.cc,v 1.410.2.1 2008/02/25 02:42:43 amosjeffries Exp $ + * $Id: stat.cc,v 1.410.2.2 2008/02/25 02:45:50 amosjeffries Exp $ * * DEBUG: section 18 Cache Manager Statistics * AUTHOR: Harvest Derived @@ -546,7 +546,7 @@ info_get(StoreEntry * sentry) storeAppendPrintf(sentry, "\tStorage Mem size:\t%d KB\n", - (mem_node::store_mem_size >> 10)); + mem_node::StoreMemSize() >> 10); storeAppendPrintf(sentry, "\tStorage Mem capacity:\t%4.1f%% used, %4.1f%% free\n", dpercent(mem_node::InUseCount(), store_pages_max), diff --git a/src/stmem.cc b/src/stmem.cc index e1837d97e1..f4862993eb 100644 --- a/src/stmem.cc +++ b/src/stmem.cc @@ -1,6 +1,6 @@ /* - * $Id: stmem.cc,v 1.92 2007/08/13 18:25:14 hno Exp $ + * $Id: stmem.cc,v 1.92.2.1 2008/02/25 02:45:50 amosjeffries Exp $ * * DEBUG: section 19 Store Memory Primitives * AUTHOR: Harvest Derived @@ -150,8 +150,6 @@ mem_hdr::writeAvailable(mem_node *aNode, int64_t location, size_t amount, char c /* Adjust the ptr and len according to what was deposited in the page */ aNode->nodeBuffer.length += copyLen; - mem_node::store_mem_size += copyLen; - return copyLen; }