You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jcs-users@jakarta.apache.org by Amy Wang <am...@intersperse.com> on 2003/05/23 02:53:07 UTC

JCS performance with auxiliary cache

Hi, 
 
Have somebody done any benchmarking on jcs?
 
I tried to write a simple load test. However, as long as the spooling flag
is on, the memory keeps increasing, eventually it went out of memory. 
 
I suppose with auxiliary disk support, it should leverage the memory load by
moving LRU objects to disk, and whenever an object is hit and is not in the
memory, it should be serialized back from disk.
 
The result shows the number of objects JCS holds is much less then if I use
the hashmap. 
I try to set UseMemoryShrinker=true, but it doesn't help. 
Is there any thing wrong with my config? 
 
Also, while I see objects getting written out to the data file, how come the
key file does not have any content, the size is always 0?
 
Thanks, 
Amy
 
 
Here is the result:
MockCacheObject: 123999 being written to disk
#objects = 125000 => total used memory = 66650112, cache key size 125000
MockCacheObject: 124999 being written to disk
#objects = 126000 => total used memory = 66650112, cache key size 126000
MockCacheObject: 125999 being written to disk
java.lang.OutOfMemoryError
 

Here is the simple load test code:
public static void addObjects(int index) throws Exception {  
  for (int i = index; i < index + 1000; i++) {
   cm.putInGroup(new Integer(i), "dummyGroup", new MockCacheObject(i,
"value:" + i));
   objectCount++;
   Thread.sleep(1);
  }
  Thread.sleep(10);
}
 
public static void main(String[] args) {
  try {
   while (true) {
    PerformanceTest.addObjects(objectCount);
 
    System.out.println("#objects = " + objectCount + " => total used memory
= " + Runtime.getRuntime().totalMemory()
      + ", cache key size " + cm.getGroupKeys("dummyGroup").size());
    
   }
  } catch (Throwable ex) {
   ex.printStackTrace();
  }
}
 

Here is the cache setting:
# JCS Config for unit testing, just a simple memory only cache
jcs.default=indexedDiskCache
jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.default.cacheattributes.MaxObjects=1000
jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru
.LRUMemoryCache
jcs.default.elementattributes.IsSpool=true
 
jcs.system.groupIdCache=
jcs.system.groupIdCache.cacheattributes=org.apache.jcs.engine.CompositeCache
Attributes
jcs.system.groupIdCache.cacheattributes.MaxObjects=10000
jcs.system.groupIdCache.cacheattributes.MemoryCacheName=org.apache.jcs.engin
e.memory.lru.LRUMemoryCache
 
# Indexed Disk Cache
jcs.auxiliary.indexedDiskCache=org.apache.jcs.auxiliary.disk.indexed.Indexed
DiskCacheFactory
jcs.auxiliary.indexedDiskCache.attributes=org.apache.jcs.auxiliary.disk.inde
xed.IndexedDiskCacheAttributes
jcs.auxiliary.indexedDiskCache.attributes.DiskPath=.\\indexed-disk-cache