/*
- * $Id: store_heap_replacement.cc,v 1.2 2000/11/03 16:38:46 wessels Exp $
+ * $Id: store_heap_replacement.cc,v 1.3 2000/11/03 16:39:42 wessels Exp $
*
* DEBUG: section 20 Storage Manager Heap-based replacement
* AUTHOR: John Dilley
* for this to become a problem. (estimation is 10^8 cache
* turnarounds)
*/
-heap_key HeapKeyGen_StoreEntry_LFUDA(void *entry, double age)
+heap_key
+HeapKeyGen_StoreEntry_LFUDA(void *entry, double age)
{
StoreEntry *e = entry;
heap_key key;
tie = 1.0 - exp((double) (e->lastref - squid_curtime) / 86400.0);
key = age + (double) e->refcount - tie;
debug(81, 3) ("HeapKeyGen_StoreEntry_LFUDA: %s refcnt=%ld lastref=%ld age=%f tie=%f -> %f\n",
- storeKeyText(e->hash.key), e->refcount, e->lastref, age, tie, key);
+ storeKeyText(e->hash.key), e->refcount, e->lastref, age, tie, key);
if (e->mem_obj && e->mem_obj->url)
debug(81, 3) ("HeapKeyGen_StoreEntry_LFUDA: url=%s\n",
e->mem_obj->url);
- return (double)key;
+ return (double) key;
}
* for this to become a problem. (estimation is 10^8 cache
* turnarounds)
*/
-heap_key HeapKeyGen_StoreEntry_GDSF(void *entry, double age)
+heap_key
+HeapKeyGen_StoreEntry_GDSF(void *entry, double age)
{
StoreEntry *e = entry;
heap_key key;
double tie = (e->lastref > 1) ? (1.0 / e->lastref) : 1.0;
key = age + ((double) e->refcount / size) - tie;
debug(81, 3) ("HeapKeyGen_StoreEntry_GDSF: %s size=%f refcnt=%ld lastref=%ld age=%f tie=%f -> %f\n",
- storeKeyText(e->hash.key), size, e->refcount, e->lastref, age, tie, key);
+ storeKeyText(e->hash.key), size, e->refcount, e->lastref, age, tie, key);
if (e->mem_obj && e->mem_obj->url)
debug(81, 3) ("HeapKeyGen_StoreEntry_GDSF: url=%s\n",
e->mem_obj->url);
* Don't use it unless you are trying to compare performance among
* heap-based replacement policies...
*/
-heap_key HeapKeyGen_StoreEntry_LRU(void *entry, double age)
+heap_key
+HeapKeyGen_StoreEntry_LRU(void *entry, double age)
{
StoreEntry *e = entry;
debug(81, 3) ("HeapKeyGen_StoreEntry_LRU: %s age=%f lastref=%f\n",
- storeKeyText(e->hash.key), age, (double)e->lastref);
+ storeKeyText(e->hash.key), age, (double) e->lastref);
if (e->mem_obj && e->mem_obj->url)
debug(81, 3) ("HeapKeyGen_StoreEntry_LRU: url=%s\n",
e->mem_obj->url);
/*
- * $Id: store_repl_heap.cc,v 1.1 2000/06/08 18:05:40 hno Exp $
+ * $Id: store_repl_heap.cc,v 1.2 2000/11/03 16:39:42 wessels Exp $
*
* DEBUG: section ? HEAP based removal policies
* AUTHOR: Henrik Nordstrom
heap_key_func *keyfunc;
int count;
int nwalkers;
- enum heap_entry_type
- { TYPE_UNKNOWN = 0, TYPE_STORE_ENTRY, TYPE_STORE_MEM }
- type;
+ enum heap_entry_type {
+ TYPE_UNKNOWN = 0, TYPE_STORE_ENTRY, TYPE_STORE_MEM
+ } type;
};
/* Hack to avoid having to remember the RemovalPolicyNode location.
HeapPolicyData *heap = policy->_data;
assert(!node->data);
if (EBIT_TEST(entry->flags, ENTRY_SPECIAL))
- return; /* We won't manage these.. they messes things up */
+ return; /* We won't manage these.. they messes things up */
node->data = heap_insert(heap->heap, entry);
heap->count += 1;
if (!heap->type)
/** RemovalPolicyWalker **/
typedef struct _HeapWalkData HeapWalkData;
-struct _HeapWalkData
-{
+struct _HeapWalkData {
int current;
};
/** RemovalPurgeWalker **/
typedef struct _HeapPurgeData HeapPurgeData;
-struct _HeapPurgeData
-{
+struct _HeapPurgeData {
link_list *locked_entries;
heap_key min_age;
};
heap->nwalkers -= 1;
if (heap_walker->min_age > 0) {
heap->heap->age = heap_walker->min_age;
- debug (81, 3) ("heap_purgeDone: Heap age set to %f\n",
- (double) heap->heap->age);
+ debug(81, 3) ("heap_purgeDone: Heap age set to %f\n",
+ (double) heap->heap->age);
}
/*
* Reinsert the locked entries