--------------------- PatchSet 5246 Date: 2007/08/11 03:49:12 Author: amosjeffries Branch: bug2000 Tag: (none) Log: Clear experimental code. Members: src/Makefile.am:1.122.10.1->1.122.10.2 src/Mem.h:1.5.28.1->1.5.28.2 src/StoreEntryStream.h:1.2.36.3->1.2.36.4 src/mem.cc:1.38.12.1->1.38.12.2 src/tests/testStoreEntryStream.cc:1.5.10.3->1.5.10.4 src/tests/testStoreEntryStream.h:1.2.12.2->1.2.12.3 test-suite/hash.h:1.1.64.2->1.1.64.3 Index: squid3/src/Makefile.am =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Makefile.am,v retrieving revision 1.122.10.1 retrieving revision 1.122.10.2 diff -u -r1.122.10.1 -r1.122.10.2 --- squid3/src/Makefile.am 4 Aug 2007 11:14:42 -0000 1.122.10.1 +++ squid3/src/Makefile.am 11 Aug 2007 03:49:12 -0000 1.122.10.2 @@ -1,7 +1,7 @@ # # Makefile for the Squid Object Cache server # -# $Id: Makefile.am,v 1.122.10.1 2007/08/04 11:14:42 amosjeffries Exp $ +# $Id: Makefile.am,v 1.122.10.2 2007/08/11 03:49:12 amosjeffries Exp $ # # Uncomment and customize the following to suit your needs: # @@ -2121,16 +2121,7 @@ # string needs mem.cc. tests_testString_SOURCES= \ - Mem.h \ mem.cc \ - mem_node.h \ - mem_node.cc \ - stmem.cc \ - MemObject.h \ - tests/stub_MemObject.cc \ - tests/stub_comm.cc \ - tests/stub_store.cc \ - cbdata.cc \ String.cc \ tests/testMain.cc \ tests/testString.cc \ Index: squid3/src/Mem.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Mem.h,v retrieving revision 1.5.28.1 retrieving revision 1.5.28.2 diff -u -r1.5.28.1 -r1.5.28.2 --- squid3/src/Mem.h 4 Aug 2007 11:14:42 -0000 1.5.28.1 +++ squid3/src/Mem.h 11 Aug 2007 03:49:12 -0000 1.5.28.2 @@ -1,6 +1,6 @@ /* - * $Id: Mem.h,v 1.5.28.1 2007/08/04 11:14:42 amosjeffries Exp $ + * $Id: Mem.h,v 1.5.28.2 2007/08/11 03:49:12 amosjeffries Exp $ * * DEBUG: section 13 High Level Memory Pool Management * AUTHOR: Harvest Derived @@ -40,7 +40,7 @@ class CacheManager; -class StoreEntry; +#include class Mem { @@ -50,8 +50,8 @@ static void RegisterWithCacheManager(CacheManager & manager); static void Stats(StoreEntry *); static void CleanIdlePools(void *unused); - static void Report(StoreEntry *sentry); - static void PoolReport(const MemPoolStats * mp_st, const MemPoolMeter * AllMeter, StoreEntry *); + static void Report(std::ostream &); + static void PoolReport(const MemPoolStats * mp_st, const MemPoolMeter * AllMeter, std::ostream &); }; #endif /* SQUID_MEM */ Index: squid3/src/StoreEntryStream.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/StoreEntryStream.h,v retrieving revision 1.2.36.3 retrieving revision 1.2.36.4 diff -u -r1.2.36.3 -r1.2.36.4 --- squid3/src/StoreEntryStream.h 11 Aug 2007 03:46:29 -0000 1.2.36.3 +++ squid3/src/StoreEntryStream.h 11 Aug 2007 03:49:12 -0000 1.2.36.4 @@ -1,6 +1,6 @@ /* - * $Id: StoreEntryStream.h,v 1.2.36.3 2007/08/11 03:46:29 amosjeffries Exp $ + * $Id: StoreEntryStream.h,v 1.2.36.4 2007/08/11 03:49:12 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -30,16 +30,15 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ + #ifndef SQUID_STORE_ENTRY_STREAM_H #define SQUID_STORE_ENTRY_STREAM_H -#if 0 /* obsoleting StoreEntryStream */ - #include "Store.h" #include -/** +/* * This class provides a streambuf interface for writing * to StoreEntries. Typical use is via a StoreEntryStream * rather than direct manipulation @@ -62,8 +61,7 @@ } protected: - /** - * flush the current buffer and the character that is overflowing + /* flush the current buffer and the character that is overflowing * to the store entry. */ virtual int_type overflow(int_type aChar = traits_type::eof()) @@ -124,5 +122,4 @@ StoreEntryStreamBuf theBuffer; }; -#endif #endif /* SQUID_STORE_ENTRY_STREAM_H */ Index: squid3/src/mem.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/mem.cc,v retrieving revision 1.38.12.1 retrieving revision 1.38.12.2 diff -u -r1.38.12.1 -r1.38.12.2 --- squid3/src/mem.cc 4 Aug 2007 11:14:42 -0000 1.38.12.1 +++ squid3/src/mem.cc 11 Aug 2007 03:49:12 -0000 1.38.12.2 @@ -1,6 +1,6 @@ /* - * $Id: mem.cc,v 1.38.12.1 2007/08/04 11:14:42 amosjeffries Exp $ + * $Id: mem.cc,v 1.38.12.2 2007/08/11 03:49:12 amosjeffries Exp $ * * DEBUG: section 13 High Level Memory Pool Management * AUTHOR: Harvest Derived @@ -34,17 +34,23 @@ */ #include "squid.h" + +#include +#include + #include "event.h" #include "CacheManager.h" #include "Mem.h" #include "memMeter.h" #include "Store.h" +#include "StoreEntryStream.h" #include "MemBuf.h" #include "SquidTime.h" /* module globals */ /* local prototypes */ +static void memStringStats(std::ostream &); /* module locals */ static MemAllocator *MemPools[MEM_MAX]; @@ -88,58 +94,66 @@ /* local routines */ static void -memStringStats(StoreEntry *sentry) +memStringStats(std::ostream &stream) { int i; int pooled_count = 0; size_t pooled_volume = 0; /* heading */ - storeAppendPrintf(sentry,"String Pool\t Impact\t\t\n \t (%%strings)\t (%%volume)\n"); + stream << "String Pool\t Impact\t\t\n \t (%strings)\t (%volume)\n"; /* table body */ for (i = 0; i < mem_str_pool_count; i++) { const MemAllocator *pool = StrPools[i].pool; const int plevel = pool->getMeter().inuse.level; - storeAppendPrintf(sentry," %20s\t %10.0d\t %10.0d\n", - pool->objectType() , - xpercentInt(plevel, StrCountMeter.level) , - xpercentInt(plevel * pool->objectSize(), StrVolumeMeter.level) ); + stream << std::setw(20) << std::left << pool->objectType(); + stream << std::right << "\t " << xpercentInt(plevel, StrCountMeter.level); + stream << "\t " << xpercentInt(plevel * pool->objectSize(), StrVolumeMeter.level) << "\n"; pooled_count += plevel; pooled_volume += plevel * pool->objectSize(); } /* malloc strings */ - storeAppendPrintf(sentry," %20s\t %10.0d\t %10.0d\n\n", - "Other Strings", - xpercentInt(StrCountMeter.level - pooled_count, StrCountMeter.level) , - xpercentInt(StrVolumeMeter.level - pooled_volume, StrVolumeMeter.level) ); + stream << std::setw(20) << std::left << "Other Strings"; + + stream << std::right << "\t "; + + stream << xpercentInt(StrCountMeter.level - pooled_count, StrCountMeter.level) << "\t "; + + stream << xpercentInt(StrVolumeMeter.level - pooled_volume, StrVolumeMeter.level) << "\n\n"; +} + +static void +memBufStats(std::ostream & stream) +{ + stream << "Large buffers: " << + HugeBufCountMeter.level << " (" << + HugeBufVolumeMeter.level / 1024 << " KB)\n"; } void Mem::Stats(StoreEntry * sentry) { - Report(sentry); - memStringStats(sentry); - - storeAppendPrintf(sentry,"Large buffers: %d (%d KB)\n", - HugeBufCountMeter.level, - HugeBufVolumeMeter.level / 1024); - + StoreEntryStream stream(sentry); + Report(stream); + memStringStats(stream); + memBufStats(stream); #if WITH_VALGRIND if (RUNNING_ON_VALGRIND) { - long int leaked = 0, dubious = 0, reachable = 0, suppressed = 0; - storeAppendPrintf(sentry,"Valgrind Report:\nType\tAmount\n"; - debugs(13, 1, "Asking valgrind for memleaks"); + long int leaked = 0, dubious = 0, reachable = 0, suppressed = 0; + stream << "Valgrind Report:\n"; + stream << "Type\tAmount\n"; + debugs(13, 1, "Asking valgrind for memleaks"); VALGRIND_DO_LEAK_CHECK; - debugs(13, 1, "Getting valgrind statistics"); - + debugs(13, 1, "Getting valgrind statistics"); VALGRIND_COUNT_LEAKS(leaked, dubious, reachable, suppressed); - storeAppendPrintf(sentry,"Leaked\t%d\n", leaked); - storeAppendPrintf(sentry,"Dubious\t%d\n", dubious); - storeAppendPrintf(sentry,"Reachable\t%d\n", reachable); - storeAppendPrintf(sentry,"Suppressed\t%d\n", suppressed); + stream << "Leaked\t" << leaked << "\n"; + stream << "Dubious\t" << dubious << "\n"; + stream << "Reachable\t" << reachable << "\n"; + stream << "Suppressed\t" << suppressed << "\n"; } #endif + stream.flush(); } /* @@ -542,19 +556,19 @@ /* MemPoolMeter */ void -Mem::PoolReport(const MemPoolStats * mp_st, const MemPoolMeter * AllMeter, StoreEntry *sentry) +Mem::PoolReport(const MemPoolStats * mp_st, const MemPoolMeter * AllMeter, std::ostream &stream) { int excess = 0; int needed = 0; MemPoolMeter *pm = mp_st->meter; const char *delim = "\t "; - storeAppendPrintf(sentry,"%20.20s%s", mp_st->label, delim); - storeAppendPrintf(sentry,"%4d%s", mp_st->obj_size, delim); + stream << std::setw(20) << std::left << mp_st->label << delim; + stream << std::setw(4) << std::right << mp_st->obj_size << delim; /* Chunks */ - storeAppendPrintf(sentry,"%4d%s", toKB(mp_st->obj_size * mp_st->chunk_capacity), delim); - storeAppendPrintf(sentry,"%4d%s", mp_st->chunk_capacity, delim); + stream << std::setw(4) << toKB(mp_st->obj_size * mp_st->chunk_capacity) << delim; + stream << std::setw(4) << mp_st->chunk_capacity << delim; if (mp_st->chunk_capacity) { needed = mp_st->items_inuse / mp_st->chunk_capacity; @@ -565,11 +579,11 @@ excess = mp_st->chunks_inuse - needed; } - storeAppendPrintf(sentry,"%4d%s", mp_st->chunks_alloc, delim); - storeAppendPrintf(sentry,"%4d%s", mp_st->chunks_inuse, delim); - storeAppendPrintf(sentry,"%4d%s", mp_st->chunks_free, delim); - storeAppendPrintf(sentry,"%4d%s", mp_st->chunks_partial, delim); - storeAppendPrintf(sentry,"%0.3f%s", xpercent(excess, needed), delim); + stream << std::setw(4) << mp_st->chunks_alloc << delim; + stream << std::setw(4) << mp_st->chunks_inuse << delim; + stream << std::setw(4) << mp_st->chunks_free << delim; + stream << std::setw(4) << mp_st->chunks_partial << delim; + stream << std::setprecision(3) << xpercent(excess, needed) << delim; /* * Fragmentation calculation: * needed = inuse.level / chunk_capacity @@ -579,26 +593,26 @@ * Fragm = (alloced - (inuse / obj_ch) ) / alloced */ /* allocated */ - storeAppendPrintf(sentry,"%d%s", mp_st->items_alloc, delim); - storeAppendPrintf(sentry,"%d%s", toKB(mp_st->obj_size * pm->alloc.level), delim); - storeAppendPrintf(sentry,"%d%s", toKB(mp_st->obj_size * pm->alloc.hwater_level), delim); - storeAppendPrintf(sentry,"%3f%s", ((squid_curtime - pm->alloc.hwater_stamp) / 3600.), delim); - storeAppendPrintf(sentry,"%3f%s", xpercent(mp_st->obj_size * pm->alloc.level, AllMeter->alloc.level), delim); + stream << mp_st->items_alloc << delim; + stream << toKB(mp_st->obj_size * pm->alloc.level) << delim; + stream << toKB(mp_st->obj_size * pm->alloc.hwater_level) << delim; + stream << std::setprecision(2) << ((squid_curtime - pm->alloc.hwater_stamp) / 3600.) << delim; + stream << std::setprecision(3) << xpercent(mp_st->obj_size * pm->alloc.level, AllMeter->alloc.level) << delim; /* in use */ - storeAppendPrintf(sentry,"%d%s", mp_st->items_inuse, delim); - storeAppendPrintf(sentry,"%d%s", toKB(mp_st->obj_size * pm->inuse.level), delim); - storeAppendPrintf(sentry,"%d%s", toKB(mp_st->obj_size * pm->inuse.hwater_level), delim); - storeAppendPrintf(sentry,"%2f%s", ((squid_curtime - pm->inuse.hwater_stamp) / 3600.), delim); - storeAppendPrintf(sentry,"%3f%s", xpercent(pm->inuse.level, pm->alloc.level), delim); + stream << mp_st->items_inuse << delim; + stream << toKB(mp_st->obj_size * pm->inuse.level) << delim; + stream << toKB(mp_st->obj_size * pm->inuse.hwater_level) << delim; + stream << std::setprecision(2) << ((squid_curtime - pm->inuse.hwater_stamp) / 3600.) << delim; + stream << std::setprecision(3) << xpercent(pm->inuse.level, pm->alloc.level) << delim; /* idle */ - storeAppendPrintf(sentry,"%d%s", mp_st->items_idle, delim); - storeAppendPrintf(sentry,"%d%s", toKB(mp_st->obj_size * pm->idle.level), delim); - storeAppendPrintf(sentry,"%d%s", toKB(mp_st->obj_size * pm->idle.hwater_level), delim); + stream << mp_st->items_idle << delim; + stream << toKB(mp_st->obj_size * pm->idle.level) << delim; + stream << toKB(mp_st->obj_size * pm->idle.hwater_level) << delim; /* saved */ - storeAppendPrintf(sentry,"%d%s", (int)pm->gb_saved.count, delim); - storeAppendPrintf(sentry,"%3f%s", xpercent(pm->gb_saved.count, AllMeter->gb_saved.count), delim); - storeAppendPrintf(sentry,"%3f%s", xpercent(pm->gb_saved.bytes, AllMeter->gb_saved.bytes), delim); - storeAppendPrintf(sentry,"%3f\n", xdiv(pm->gb_saved.count - pm->gb_osaved.count, xm_deltat) ); + stream << (int)pm->gb_saved.count << delim; + stream << std::setprecision(3) << xpercent(pm->gb_saved.count, AllMeter->gb_saved.count) << delim; + stream << std::setprecision(3) << xpercent(pm->gb_saved.bytes, AllMeter->gb_saved.bytes) << delim; + stream << std::setprecision(3) << xdiv(pm->gb_saved.count - pm->gb_osaved.count, xm_deltat) << "\n"; pm->gb_osaved.count = pm->gb_saved.count; } @@ -634,7 +648,7 @@ } void -Mem::Report(StoreEntry *sentry) +Mem::Report(std::ostream &stream) { static char buf[64]; static MemPoolStats mp_stats; @@ -644,26 +658,25 @@ MemAllocator *pool; /* caption */ - storeAppendPrintf(sentry,"Current memory usage:\n"); + stream << "Current memory usage:\n"; /* heading */ - storeAppendPrintf(sentry, - "Pool\t Obj Size\t" - "Chunks\t\t\t\t\t\t\t" - "Allocated\t\t\t\t\t" - "In Use\t\t\t\t\t" - "Idle\t\t\t" - "Allocations Saved\t\t\t" - "Hit Rate\t" - "\n" - " \t (bytes)\t" - "KB/ch\t obj/ch\t" - "(#)\t used\t free\t part\t %%Frag\t " - "(#)\t (KB)\t high (KB)\t high (hrs)\t %%Tot\t" - "(#)\t (KB)\t high (KB)\t high (hrs)\t %%alloc\t" - "(#)\t (KB)\t high (KB)\t" - "(#)\t %%cnt\t %%vol\t" - "(#) / sec\t" - "\n"); + stream << "Pool\t Obj Size\t" + "Chunks\t\t\t\t\t\t\t" + "Allocated\t\t\t\t\t" + "In Use\t\t\t\t\t" + "Idle\t\t\t" + "Allocations Saved\t\t\t" + "Hit Rate\t" + "\n" + " \t (bytes)\t" + "KB/ch\t obj/ch\t" + "(#)\t used\t free\t part\t %Frag\t " + "(#)\t (KB)\t high (KB)\t high (hrs)\t %Tot\t" + "(#)\t (KB)\t high (KB)\t high (hrs)\t %alloc\t" + "(#)\t (KB)\t high (KB)\t" + "(#)\t %cnt\t %vol\t" + "(#) / sec\t" + "\n"; xm_deltat = current_dtime - xm_time; xm_time = current_dtime; @@ -693,7 +706,7 @@ qsort(sortme, npools, sizeof(*sortme), MemPoolReportSorter); for (int i = 0; i< npools; i++) { - PoolReport(&sortme[i], mp_total.TheMeter, sentry); + PoolReport(&sortme[i], mp_total.TheMeter, stream); } xfree(sortme); @@ -713,19 +726,17 @@ mp_stats.items_idle = mp_total.tot_items_idle; mp_stats.overhead = mp_total.tot_overhead; - PoolReport(&mp_stats, mp_total.TheMeter, sentry); + PoolReport(&mp_stats, mp_total.TheMeter, stream); /* Cumulative */ - storeAppendPrintf(sentry,"Cumulative allocated volume: %s\n", - double_to_str(buf, 64, mp_total.TheMeter->gb_saved.bytes) ); + stream << "Cumulative allocated volume: "<< double_to_str(buf, 64, mp_total.TheMeter->gb_saved.bytes) << "\n"; /* overhead */ - storeAppendPrintf(sentry,"Current overhead: %d bytes (%0.3f%%)\n", - mp_total.tot_overhead, - xpercent(mp_total.tot_overhead, mp_total.TheMeter->inuse.level) ); + stream << "Current overhead: " << mp_total.tot_overhead << " bytes (" << + std::setprecision(3) << xpercent(mp_total.tot_overhead, mp_total.TheMeter->inuse.level) << "%)\n"; /* limits */ - storeAppendPrintf(sentry,"Idle pool limit: %0.2f MB\n", toMB(mp_total.mem_idle_limit) ); + stream << "Idle pool limit: " << std::setprecision(2) << toMB(mp_total.mem_idle_limit) << " MB\n"; /* limits */ - storeAppendPrintf(sentry,"Total Pools created: %d", mp_total.tot_pools_alloc ); - storeAppendPrintf(sentry,"Pools ever used: %d (shown above)\n", mp_total.tot_pools_alloc - not_used ); - storeAppendPrintf(sentry,"Currently in use: %d", mp_total.tot_pools_inuse ); + stream << "Total Pools created: " << mp_total.tot_pools_alloc << "\n"; + stream << "Pools ever used: " << mp_total.tot_pools_alloc - not_used << " (shown above)\n"; + stream << "Currently in use: " << mp_total.tot_pools_inuse << "\n"; } Index: squid3/src/tests/testStoreEntryStream.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/tests/testStoreEntryStream.cc,v retrieving revision 1.5.10.3 retrieving revision 1.5.10.4 diff -u -r1.5.10.3 -r1.5.10.4 --- squid3/src/tests/testStoreEntryStream.cc 11 Aug 2007 03:46:29 -0000 1.5.10.3 +++ squid3/src/tests/testStoreEntryStream.cc 11 Aug 2007 03:49:13 -0000 1.5.10.4 @@ -1,6 +1,3 @@ - -#if 0 /* obsolete StoreEntryStream */ - #include "squid.h" #include "Mem.h" #include "testStore.h" @@ -57,5 +54,3 @@ Store::Root(NULL); } - -#endif Index: squid3/src/tests/testStoreEntryStream.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/tests/testStoreEntryStream.h,v retrieving revision 1.2.12.2 retrieving revision 1.2.12.3 diff -u -r1.2.12.2 -r1.2.12.3 --- squid3/src/tests/testStoreEntryStream.h 4 Aug 2007 13:02:43 -0000 1.2.12.2 +++ squid3/src/tests/testStoreEntryStream.h 11 Aug 2007 03:49:13 -0000 1.2.12.3 @@ -2,8 +2,6 @@ #ifndef SQUID_SRC_TEST_STORE_ENTRY_STREAM_H #define SQUID_SRC_TEST_STORE_ENTRY_STREAM_H -#if 0 /* obsolete StoreEntryStream */ - #include /* @@ -25,4 +23,3 @@ #endif -#endif Index: squid3/test-suite/hash.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/test-suite/hash.h,v retrieving revision 1.1.64.2 retrieving revision 1.1.64.3 diff -u -r1.1.64.2 -r1.1.64.3 --- squid3/test-suite/hash.h 4 Aug 2007 11:19:25 -0000 1.1.64.2 +++ squid3/test-suite/hash.h 11 Aug 2007 03:49:13 -0000 1.1.64.3 @@ -22,11 +22,8 @@ typedef struct _hash_table hash_table; extern int hash_links_allocated; -#if 0 - /* AYJ: g++ 4.1.3+ says: previously declared n globals.h */ extern int store_hash_buckets; /* 0 */ extern hash_table *store_table; /* NULL */ -#endif extern hash_table *hash_create(HASHCMP *, int, HASHHASH *); extern void hash_insert(hash_table *, const char *, void *); extern int hash_delete(hash_table *, const char *);