--------------------- PatchSet 2165 Date: 2001/04/30 20:24:39 Author: akroonmaa Branch: chunked_mempools Tag: (none) Log: cleanup dirty hacks Members: src/MemPoolStats.c:1.1.2.12->1.1.2.13 Index: squid/src/MemPoolStats.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/MemPoolStats.c,v retrieving revision 1.1.2.12 retrieving revision 1.1.2.13 diff -u -r1.1.2.12 -r1.1.2.13 --- squid/src/MemPoolStats.c 30 Apr 2001 19:35:30 -0000 1.1.2.12 +++ squid/src/MemPoolStats.c 30 Apr 2001 20:24:39 -0000 1.1.2.13 @@ -54,7 +54,7 @@ /* local prototypes */ static void memPoolDescribe(const MemPool * pool); static void memShrink(ssize_t new_limit); -static void memPoolReport(const MemPool * pool, StoreEntry * e); +static void memPoolReport(const MemPool * pool, int freecount, int partial, StoreEntry * e); static double toMB(size_t size) @@ -206,8 +206,8 @@ { assert(pm); storeAppendPrintf(e, - "%d\t %d\t %d\t %.2f\t %d\t" /* alloc */ - "%d\t %d\t %d\t %d\t" /* in use */ + "%d\t %d\t %d\t %.2f\t %.1f\t" /* alloc */ + "%d\t %d\t %d\t %.1f\t" /* in use */ "%d\t %d\t %d\t" /* idle */ "%.0f\t %.1f\t %.1f\t %.1f\n", /* saved */ /* alloc */ @@ -215,17 +215,16 @@ toKB(obj_size * pm->alloc.level), toKB(obj_size * pm->alloc.hwater_level), (double) ((squid_curtime - pm->alloc.hwater_stamp) / 3600.), - xpercentInt(obj_size * pm->alloc.level, TheMeter.alloc.level), + xpercent(obj_size * pm->alloc.level, TheMeter.alloc.level), /* in use */ inuse_count, toKB(obj_size * pm->inuse.level), toKB(obj_size * pm->inuse.hwater_level), - xpercentInt(pm->inuse.level, pm->alloc.level), + xpercent(pm->inuse.level, pm->alloc.level), /* idle */ idle_count, toKB(obj_size * pm->idle.level), toKB(obj_size * pm->idle.hwater_level), - /* (int)rint(xpercent(pm->idle.level, pm->alloc.level)), */ /* saved */ pm->gb_saved.count, xpercent(pm->gb_saved.count, TheMeter.gb_saved.count), @@ -244,30 +243,17 @@ toKB(pool->obj_size * pool->meter.inuse.level)); } -/* These should be moved into the MemPool statistics... */ -static int freecount; /* need these outside memPoolReport() */ -static int partial; -static int inuse; - static void -memPoolReport(const MemPool * pool, StoreEntry * e) +memPoolReport(const MemPool * pool, int freecount, int partial, StoreEntry * e) { int excess, needed; - MemChunk *chunk; + int inuse; assert(pool); storeAppendPrintf(e, "%-20s\t %4d\t ", pool->label, pool->obj_size); storeAppendPrintf(e, "%4d\t %4d\t ", toKB(pool->obj_size * pool->capacity), pool->capacity); - freecount = partial = 0; - chunk = pool->Chunks; - while (chunk) { - if (chunk->inuse_count == 0) - freecount++; - else if (chunk->inuse_count < pool->capacity) - partial++; - chunk = chunk->next; - } + inuse = pool->chunkCount - freecount; if (pool->meter.inuse.level % pool->capacity) @@ -304,6 +290,10 @@ int nuse_count = 0; int free_count = 0; int part_count = 0; + MemChunk *chunk; + int freecount; + int partial; + int inuse; int i; /* caption */ storeAppendPrintf(e, "Current memory usage:\n"); @@ -334,7 +324,18 @@ MemPool *pool = Pools.items[i]; memPoolClean(pool, (time_t) 555555); /* don't want to get chunks released before reporting */ if (pool->meter.inuse.hwater_level > 0) { /* this pool has been used */ - memPoolReport(pool, e); + freecount = partial = 0; + chunk = pool->Chunks; + while (chunk) { + if (chunk->inuse_count == 0) + freecount++; + else if (chunk->inuse_count < pool->capacity) + partial++; + chunk = chunk->next; + } + inuse = pool->chunkCount - freecount; + memPoolReport(pool, freecount, partial, e); + free_count += freecount; part_count += partial; nuse_count += inuse;