]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Added back some rudimentary removal policy statistics (only implemented
authorhno <>
Wed, 4 Jul 2001 06:12:05 +0000 (06:12 +0000)
committerhno <>
Wed, 4 Jul 2001 06:12:05 +0000 (06:12 +0000)
for the "lru" policy as of yet)

  policy.Stat(policy, sentry)

  appends policy statistics to sentry

doc/Programming-Guide/prog-guide.sgml
src/repl/lru/store_repl_lru.cc
src/store_dir.cc
src/structs.h

index 1139447ec7c9d81c7c9b470d3a127dcbeaf0c007..008e3f18cc7dcf8a34beb56bf1505c6c24656aef 100644 (file)
@@ -2,7 +2,7 @@
 <article>
 <title>Squid Programmers Guide</title>
 <author>Duane Wessels, Squid Developers
-<date>$Id: prog-guide.sgml,v 1.44 2001/06/18 16:34:15 wessels Exp $</date>
+<date>$Id: prog-guide.sgml,v 1.45 2001/07/04 00:12:05 hno Exp $</date>
 
 <abstract>
 Squid is a WWW Cache application developed by the National Laboratory
@@ -1768,18 +1768,26 @@ coupling between the storage layer and the replacement policy.
        Finishes a walk of the maintained objects, destroys
        walker and restores the policy to it's normal state.
 
-<sect2>Future removal policy implementation
+<sect3>policy.Stats()
 
-<sect3>Source layout
+<P>
+<verb>
+       purgewalker-&gt;Stats(RemovalPurgeWalker *purgewalker, StoreEntry *entry)
+</verb>
+
+       <P>
+       Appends statistics about the policy to the given entry.
+
+<sect2>Source layout
 
 <P>
        Policy implementations resides in src/repl/&lt;name&gt;/, and a make in
        such a directory must result in a object archive src/repl/&lt;name&gt;.a
        containing all the objects implementing the policy.
 
-<sect3>Internal structures
+<sect2>Internal structures
 
-<sect4>RemovalPolicy
+<sect3>RemovalPolicy
 
 <P>
 <verb>
@@ -1800,7 +1808,7 @@ coupling between the storage layer and the replacement policy.
 <P>
        The _data member is for storing policy specific information.
 
-<sect4>RemovalPolicyWalker
+<sect3>RemovalPolicyWalker
 
 <P>
 <verb>
@@ -1813,7 +1821,7 @@ coupling between the storage layer and the replacement policy.
        };
 </verb>
 
-<sect4>RemovalPolicyNode
+<sect3>RemovalPolicyNode
 
 <P>
 <verb>
@@ -1828,7 +1836,7 @@ coupling between the storage layer and the replacement policy.
        maybe later provide more space here to allow simple policies
        to store all their data "inline" to preserve some memory.
 
-<sect3>Policy registration
+<sect2>Policy registration
 
 <P>
        Policies are automatically registered in the Squid binary from the
@@ -1836,7 +1844,7 @@ coupling between the storage layer and the replacement policy.
        might get extended to support loadable modules. All registered
        policies are available to object stores which wishes to use them.
 
-<sect3>Policy instance creation
+<sect2>Policy instance creation
 
 <P>
        Each policy must implement a "create/new" function "<tt/RemovalPolicy *
@@ -1850,7 +1858,7 @@ coupling between the storage layer and the replacement policy.
        It should also populate the _data member with a pointer to policy
        specific data.
 
-<sect3>Walker
+<sect2>Walker
 
 <P>
        When a walker is created the policy populates it with at least the API
index 851e13bae0cead41ba0462f92d66ec3325b8cd63..7fd4d82fbd49bea4f319cfb837067ee385fa3cd9 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_repl_lru.cc,v 1.8 2001/03/03 10:39:39 hno Exp $
+ * $Id: store_repl_lru.cc,v 1.9 2001/07/04 00:12:06 hno Exp $
  *
  * DEBUG: section ?     LRU Removal policy
  * AUTHOR: Henrik Nordstrom
@@ -242,6 +242,23 @@ lru_purgeInit(RemovalPolicy * policy, int max_scan)
     return walker;
 }
 
+static void
+lru_stats(RemovalPolicy * policy, StoreEntry * sentry)
+{
+    LruPolicyData *lru = policy->_data;
+    LruNode *lru_node = (LruNode *)lru->list.head;
+
+again:
+    if (lru_node) {
+       StoreEntry * entry = (StoreEntry *) lru_node->node.data;
+       if (storeEntryLocked(entry)) {
+           lru_node = (LruNode *)lru_node->node.next;
+           goto again;
+       }
+       storeAppendPrintf(sentry, "LRU reference age: %.2f days\n", (double) (squid_curtime - entry->lastref) / (double) (24 * 60 * 60));
+    }
+}
+
 static void
 lru_free(RemovalPolicy * policy)
 {
@@ -281,6 +298,7 @@ createRemovalPolicy_lru(wordlist * args)
     policy->Dereferenced = lru_referenced;
     policy->WalkInit = lru_walkInit;
     policy->PurgeInit = lru_purgeInit;
+    policy->Stats = lru_stats;
     /* Increase policy usage count */
     nr_lru_policies += 0;
     return policy;
index b336cb606d3c02787d620b75b8cb539d0b2b60b1..601e067892f0e0d3d0f21cf8e0c7e63de17bf36a 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_dir.cc,v 1.130 2001/03/28 16:33:56 wessels Exp $
+ * $Id: store_dir.cc,v 1.131 2001/07/04 00:12:05 hno Exp $
  *
  * DEBUG: section 47    Store Directory Routines
  * AUTHOR: Duane Wessels
@@ -288,6 +288,7 @@ storeDirStats(StoreEntry * sentry)
     storeAppendPrintf(sentry, "Current Capacity       : %d%% used, %d%% free\n",
        percent((int) store_swap_size, (int) Config.Swap.maxSize),
        percent((int) (Config.Swap.maxSize - store_swap_size), (int) Config.Swap.maxSize));
+    /* FIXME Here we should output memory statistics */
 
     /* Now go through each swapdir, calling its statfs routine */
     for (i = 0; i < Config.cacheSwap.n_configured; i++) {
@@ -298,6 +299,11 @@ storeDirStats(StoreEntry * sentry)
        storeAppendPrintf(sentry, "FS Block Size %d Bytes\n",
            SD->fs.blksize);
        SD->statfs(SD, sentry);
+       if (SD->repl) {
+           storeAppendPrintf(sentry, "Removal policy: %s\n", SD->repl->_type);
+           if (SD->repl->Stats)
+               SD->repl->Stats(SD->repl, sentry);
+       }
     }
 }
 
index 675cd6d5598d31f4e5d87d800654939089a736a7..df8e383fa6a9a8383fc079015f80c946a633cefb 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: structs.h,v 1.392 2001/06/29 14:48:06 hno Exp $
+ * $Id: structs.h,v 1.393 2001/07/04 00:12:05 hno Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -1406,6 +1406,7 @@ struct _RemovalPolicy {
     void (*Dereferenced) (RemovalPolicy * policy, const StoreEntry * entry, RemovalPolicyNode * node);
     RemovalPolicyWalker *(*WalkInit) (RemovalPolicy * policy);
     RemovalPurgeWalker *(*PurgeInit) (RemovalPolicy * policy, int max_scan);
+    void (*Stats) (RemovalPolicy * policy, StoreEntry * entry);
 };
 
 struct _RemovalPolicyWalker {