Change proposal: Filter eviction events
bdueck Jan 6, 2006 10:23 AMBen;
One of the performance enhancements I'd like to contribute relates to optimizing eviction handling filter eviction nodes.
Can you give me your thoughts on the proposed change below?
- In my scenario using JBossCache, I have certain subtrees in the cache that must be treated atomically from an eviction perspective. i.e. I can't allow just one branch of the subtree to be evicted. The whole subtree needs to be evicted at once, not just piece by piece.
- In JBoss 1.2.3 and prior, it was possible to support this scenario by implementing my own eviction policy (CascadingLRUPolicy) by subclassing LRUPolicy and overriding the evict() method.
- Since my "atomic subtrees" always started just off the cache root so I just ignored any evict() calls except where Fqn.size() == 1.
- I then made a further optimization by overriding the TreeCacheListener methods implemented on LRUPolicy to filter out any eviction events prior to them getting inserted into the bounded buffer. The rational was that since I wasn't interesed in evicting certain nodes, I could save a bunch of time by simply causing JBossCache to ignore those events in the first place.
- The result was a big jump in performance and scalability in my tests.
- While it is still possible to implement the evict() portion of my CascadingLRUPolicy, it looks like some refactoring and redesign in 1.2.4 of how eviction policies and the region manager interract makes it impossible to implement the filtering optimiziation.
- So here's what I've done to re-add the functionality based on the current JBoss 1.2.4 (head):
org.jboss.cache.eviction.EvictionPolicy
- added a new method called EvictionPolicy.canIgnoreEvent(Fqn)
- canIgnoreEvent is called by RegionManager.EvictionTreeCacheListener prior to adding the event to the region event buffer.
- if canIgnoreEvent returns true, the event is not added to the region event buffer
- if canIgnoreEvent returns false (default), the event is added to the region event buffer as normal
org.jboss.cache.eviction.RegionManager
- added calls to EvictionPolicy.canIgnoreEvent in EvictionTreeCacheListener and AOPEvictionTreeCacheListener
org.jboss.cache.eviction.BaseEvictionPolicy
- provide default implementation of canIgnoreEvent that always returns false