Sun Oct 17 02:34:36 CEST 1999 Modified Files in squid/src stat.c Improvements and additions to cachemgr functions for listing cache contents * Listing given slightly higher priority. Especially noticeable on the VM related listings. * Added "Lost StoreEntry structures" for listing objects which is neither in memory or on disk. * Added "Large In-Memory and In-Transit Objects" showing objects which takes up an proportionally large portion if the VM cache. ----------------------------------------------------------------- Index: squid/src/stat.c diff -u squid/src/stat.c:1.1.1.35.2.6 squid/src/stat.c:1.1.1.35.2.7 --- squid/src/stat.c:1.1.1.35.2.6 Tue Jul 27 19:34:37 1999 +++ squid/src/stat.c Sun Oct 17 02:34:35 1999 @@ -66,6 +66,8 @@ #if DEBUG_OPENFD static OBJH statOpenfdObj; #endif +static OBJH statLargeVmObjects; +static OBJH statLostObjects; static EVH statObjects; static OBJH info_get; static OBJH statFiledescriptors; @@ -304,32 +306,36 @@ { StatObjectsState *state = data; StoreEntry *e; + int n = 0; hash_link *link_ptr = NULL; hash_link *link_next = NULL; - if (state->bucket >= store_hash_buckets) { - storeComplete(state->sentry); - storeUnlockObject(state->sentry); - cbdataFree(state); - return; - } else if (EBIT_TEST(state->sentry->flags, ENTRY_ABORTED)) { - storeUnlockObject(state->sentry); - cbdataFree(state); - return; - } else if (fwdCheckDeferRead(-1, state->sentry)) { - eventAdd("statObjects", statObjects, state, 0.1, 1); - return; - } - storeBuffer(state->sentry); - debug(49, 3) ("statObjects: Bucket #%d\n", state->bucket); - link_next = hash_get_bucket(store_table, state->bucket); - while (NULL != (link_ptr = link_next)) { - link_next = link_ptr->next; - e = (StoreEntry *) link_ptr; - if (state->filter && 0 == state->filter(e)) - continue; - statStoreEntry(state->sentry, e); + for (n = 0; n < 100; n++) { + if (state->bucket >= store_hash_buckets) { + storeComplete(state->sentry); + storeUnlockObject(state->sentry); + cbdataFree(state); + return; + } else if (EBIT_TEST(state->sentry->flags, ENTRY_ABORTED)) { + storeUnlockObject(state->sentry); + cbdataFree(state); + return; + } else if (fwdCheckDeferRead(-1, state->sentry)) { + eventAdd("statObjects", statObjects, state, 0.1, 1); + return; + } + storeBuffer(state->sentry); + debug(49, 3) ("statObjects: Bucket #%d\n", state->bucket); + link_next = hash_get_bucket(store_table, state->bucket); + while (NULL != (link_ptr = link_next)) { + link_next = link_ptr->next; + e = (StoreEntry *) link_ptr; + if (state->filter && 0 == state->filter(e)) + continue; + statStoreEntry(state->sentry, e); + n++; + } + state->bucket++; } - state->bucket++; eventAdd("statObjects", statObjects, state, 0.0, 1); storeBufferFlush(state->sentry); } @@ -363,6 +369,34 @@ statObjectsStart(sentry, statObjectsVmFilter); } +static int +statLargeVmObjectsFilter(const StoreEntry * e) +{ + MemObject *mem = e->mem_obj; + if (!mem) + return 0; + + return mem->inmem_hi - mem->inmem_lo > Config.memMaxSize / 64; +} + +static void +statLargeVmObjects(StoreEntry * sentry) +{ + statObjectsStart(sentry, statLargeVmObjectsFilter); +} + +static int +statLostOjectsFilter(const StoreEntry * e) +{ + return !e->mem_obj && e->swap_file_number == -1; +} + +static void +statLostObjects(StoreEntry * sentry) +{ + statObjectsStart(sentry, statLostOjectsFilter); +} + #if DEBUG_OPENFD static int statObjectsOpenfdFilter(const StoreEntry * e) @@ -830,6 +864,12 @@ cachemgrRegister("vm_objects", "In-Memory and In-Transit Objects", stat_vmobjects_get, 0, 0); + cachemgrRegister("vm_largeobjects", + "Large In-Memory and In-Transit Objects", + statLargeVmObjects, 0, 0); + cachemgrRegister("lostobjects", + "Lost StoreEntry structures", + statLostObjects, 0, 0); #if DEBUG_OPENFD cachemgrRegister("openfd_objects", "Objects with Swapout files open",