You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Jean-Jacques Clar <JJ...@novell.com> on 2003/11/19 19:34:58 UTC

bug between mem_cache and the max heap?

The heap in cache_pqueue is a max head, it always keep the object
with the highest priority in its root position. The object with the
highest
priority is the one that is ejected when a new element has to be 
inserted when the cache is full (max nb of entities or size reached).
 
The return value of the set priority functions in mod_mem_cache.c: 
memcache_lru_algorithm(), 
memcache_gdsf_algorithm() 
and the get_priority() function 
have to be consistent to make sure the heap is bubbling and percolating
correctly.
 
Right now set_pri() return a negative value and get_pri() a positive
value.
Because mem_cache increments the priority field based on the number of
request
and the relative time an entity is inserted in the cache, both should
return a negative value,
to use correctly the max heap.
 
The attached patch is a way to fix that problem, not sure if it is the
best. The max heap
could also be turned into a min heap, but it is probably easier to fix
mem_cache. 
 
thanks,
 
Jean-Jacques