On 8 Feb 2007, at 19:19, Mircea Markus wrote:
Hi guys,
I've walked around eviction policies and here are some thoughts
1) There is an eviction policy algorithm more efficient than LRU
(which I found quite popular) - Adaptive Replacement Policy. The
basic idea is to not rely only on the time of last access to the
node, but also on the number of time(frequency) a given node was
accessed. Here it is a nice description of how it works: http://
en.wikipedia.org/wiki/Adaptive_Replacement_Cache.
This actually is quite interesting. Something to look into.
2) One other type of eviction which I found handy is a time based
eviction, i.e. the node will be removed from the cache after a
certain time(countdown starts when it is added). A common use case
for this is when one needs an info from database, which might be
changed, but is not critical to have it visible in real time.
I believe we do time-based eviction - FIFO with maxAge.
3) Memory based eviction policy. Very useful in the case in which
cache is used for storing very heterogeneous objects - from the
size point of view. If the objects are large one is assured that
the cache won't exhaust system memory and in the case of small
objects the cache manages to store much more than it does if it
would use a static defined policy, like LRU. The most appropriate
way (I found) for measuring object size is shipped within JDK5,
through Instrumentation.getObjectSize. The MAJOR drawback is
performance: method returns only the size of the base object; for
all aggregated objects one will have to iterate recursively over
the object graph and calculate size - costly both as performance
and as memory. I don't have the complete picture on the JBC usage
scenarios ( e.g. this might be useful in a scenario in which
addition is rare and memory size is critical) so perhaps you guys
can point out whether or not this is feasible. Perhaps in the case
of PojoCache in which object are introspected anyway?
Like you said getObjectSize is expensive... so not very good if you
have a lot of short-lived objects in mem. OTOH, like you said for
PojoCache where objects are broken down, it may not be that
expensive. Sizes could be calculated once when objects are put into
the cache, for example.
Any thoughts?
Cheers,
Mircea
_______________________________________________
jbosscache-dev mailing list
jbosscache-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jbosscache-dev