From: hno <> Date: Wed, 4 Jul 2001 06:12:05 +0000 (+0000) Subject: Added back some rudimentary removal policy statistics (only implemented X-Git-Tag: SQUID_3_0_PRE1~1474 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8a3e7d9e5b547635cbe619559e8ecdee64f1562f;p=thirdparty%2Fsquid.git Added back some rudimentary removal policy statistics (only implemented for the "lru" policy as of yet) policy.Stat(policy, sentry) appends policy statistics to sentry --- diff --git a/doc/Programming-Guide/prog-guide.sgml b/doc/Programming-Guide/prog-guide.sgml index 1139447ec7..008e3f18cc 100644 --- a/doc/Programming-Guide/prog-guide.sgml +++ b/doc/Programming-Guide/prog-guide.sgml @@ -2,7 +2,7 @@
Squid Programmers Guide Duane Wessels, Squid Developers -$Id: prog-guide.sgml,v 1.44 2001/06/18 16:34:15 wessels Exp $ +$Id: prog-guide.sgml,v 1.45 2001/07/04 00:12:05 hno Exp $ 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. -Future removal policy implementation +policy.Stats() -Source layout +

+ + purgewalker->Stats(RemovalPurgeWalker *purgewalker, StoreEntry *entry) + + +

+ Appends statistics about the policy to the given entry. + +Source layout

Policy implementations resides in src/repl/<name>/, and a make in such a directory must result in a object archive src/repl/<name>.a containing all the objects implementing the policy. -Internal structures +Internal structures -RemovalPolicy +RemovalPolicy

@@ -1800,7 +1808,7 @@ coupling between the storage layer and the replacement policy.

The _data member is for storing policy specific information. -RemovalPolicyWalker +RemovalPolicyWalker

@@ -1813,7 +1821,7 @@ coupling between the storage layer and the replacement policy. }; -RemovalPolicyNode +RemovalPolicyNode

@@ -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. -Policy registration +Policy registration

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. -Policy instance creation +Policy instance creation

Each policy must implement a "create/new" function "Walker +Walker

When a walker is created the policy populates it with at least the API diff --git a/src/repl/lru/store_repl_lru.cc b/src/repl/lru/store_repl_lru.cc index 851e13bae0..7fd4d82fbd 100644 --- a/src/repl/lru/store_repl_lru.cc +++ b/src/repl/lru/store_repl_lru.cc @@ -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; diff --git a/src/store_dir.cc b/src/store_dir.cc index b336cb606d..601e067892 100644 --- a/src/store_dir.cc +++ b/src/store_dir.cc @@ -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); + } } } diff --git a/src/structs.h b/src/structs.h index 675cd6d559..df8e383fa6 100644 --- a/src/structs.h +++ b/src/structs.h @@ -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 {