]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Author: hno
authoramosjeffries <>
Mon, 25 Feb 2008 09:45:50 +0000 (09:45 +0000)
committeramosjeffries <>
Mon, 25 Feb 2008 09:45:50 +0000 (09:45 +0000)
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..

src/mem_node.cc
src/mem_node.h
src/snmp_agent.cc
src/stat.cc
src/stmem.cc

index dc44b48978343528b2ba8c996219790fd1476216..d68e220383f6948a962f09b9451e641cf68efa93 100644 (file)
@@ -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
 {
index 15a20c98e90461a288199473c2936154840646a9..28a36f16ab1e50fc10ff505521adee8d3e1d96d8 100644 (file)
@@ -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);
index d57bc55e8149ebd54fd706b48f6404ac6d1f15ae..85775504088e1230f6764a8b5a8964553cf3cb97 100644 (file)
@@ -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;
 
index 7a13dfcc942011c1835d8fe1e2758c0d280eab7c..b234aa9d4e25867317fc3f89d34d05c704b3ec1d 100644 (file)
@@ -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),
index e1837d97e1ca926d6f511cd269b7aac7f4fd3b6e..f4862993eb6ba8f29f2b5e011909301a29354002 100644 (file)
@@ -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;
 }