1 Reply Latest reply on Aug 7, 2006 9:39 PM by z c

    TreeCache performance with 1,000,000 nodes

    z c Newbie

      Hi,
      For currently evict policy only support node level. so I use one onde to store one object. but I hit some problem when implement that.
      Had anyone tried put 1,000,000 nodes in TreeCache. when using JDBC cache loader(local mysql database), the performance is quite poor while BdbjeCacheLoader is good for previout 400,000.

      after that, the program will hang.

      is there any limitation of max nodes of treecache or i miss something ?

      package org.jboss.cache.passivation;
      
      import java.io.Serializable;
      import java.util.Properties;
      
      import javax.naming.Context;
      import javax.naming.InitialContext;
      import javax.transaction.UserTransaction;
      
      import org.apache.commons.logging.Log;
      import org.apache.commons.logging.LogFactory;
      import org.jboss.cache.CacheException;
      import org.jboss.cache.Fqn;
      import org.jboss.cache.PropertyConfigurator;
      import org.jboss.cache.TreeCache;
      import org.jboss.cache.loader.CacheLoader;
      import org.jboss.cache.loader.SamplePojo;
      
      public class TestPassivation1 {
      
       TreeCache cache = null;
       CacheLoader loader = null;
      
       /**
       * @param args
       */
       public static void main(String[] args) throws Exception {
       TestPassivation1 tester = new TestPassivation1();
       tester.start();
       long start = System.currentTimeMillis();
       tester.test1();
       System.out.println("/test/0" + tester.cache.get(Fqn.fromString("/test/0"),"0"));
       tester.print(10);
       Thread.sleep(10000);
      
       System.out.println("/test/1" + tester.cache.get(Fqn.fromString("/test/1"),"1"));
       tester.print(10);
      
       long end = System.currentTimeMillis();
       System.out.println(end - start);
      
       tester.stop();
       }
      
      
      
       private void test1() throws Exception{
       long start = 0;
       long end = 0;
       start = System.currentTimeMillis();
       for(int j = 0; j < 100000; j ++){
       cache.put("/test/" +(j) ,"" + j,"Object" + j);
       }
       end = System.currentTimeMillis();
       System.out.println("cost :" + (end-start));
       for(int j = 0; j < 1000; j ++){
       start = System.currentTimeMillis();
       for(int i = 0; i < 1000; i ++){
       cache.put("/test" + j + "/" +(i) ,"" + i,"Object" + i);
       }
       end = System.currentTimeMillis();
       System.out.println("cost " + j + ":" + (end-start));
      // if(j % 20 == 0){
      // System.gc();
      // }
       }
      
       }
      
       private void print(int count) throws Exception{
       for(int i = 0; i < count; i ++){
       System.out.println("Cache exists [/test/" + i + "]:" + cache.exists("/test/" + i));
       }
       for(int i = 0; i < count; i ++){
       System.out.println("Loader exists [/test/" + i + "]:" + loader.exists(Fqn.fromString("/test/" + i)));
       }
       }
      
       private void start() throws Exception{
       cache = new TreeCache();
       PropertyConfigurator pc = new PropertyConfigurator();
       pc.configure(cache, "META-INF/tree-service1.xml");
      
       cache.createService();
       cache.startService();
       loader = cache.getCacheLoader();
      
       }
      
      
       private void stop() throws Exception{
       cache.remove("/");
       loader.remove(Fqn.fromString("/"));
       cache.stopService();
       cache.destroyService();
       }
      
      }
      

      <?xml version="1.0" encoding="UTF-8"?>
      
      <!-- ===================================================================== -->
      <!-- -->
      <!-- Sample TreeCache Service Configuration -->
      <!-- -->
      <!-- ===================================================================== -->
      
      <server>
      
       <classpath codebase="./lib" archives="jboss-cache.jar, jgroups.jar"/>
      
      
       <!-- ==================================================================== -->
       <!-- Defines TreeCache configuration -->
       <!-- ==================================================================== -->
      
       <mbean code="org.jboss.cache.TreeCache"
       name="jboss.cache:service=testTreeCache">
      
       <depends>jboss:service=Naming</depends>
       <depends>jboss:service=TransactionManager</depends>
       <attribute name="UseReplQueue">false</attribute>
       <attribute name="TransactionManagerLookupClass">org.jboss.cache.DummyTransactionManagerLookup</attribute>
      
       <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
      
       <attribute name="CacheMode">LOCAL</attribute>
      
       <attribute name="ClusterName">TreeCache-Cluster</attribute>
      
       <attribute name="InitialStateRetrievalTimeout">20000</attribute>
      
       <attribute name="SyncReplTimeout">15000</attribute>
      
       <attribute name="LockAcquisitionTimeout">10000</attribute>
      
       <attribute name="EvictionPolicyClass">org.jboss.cache.eviction.LRUPolicy</attribute>
       <attribute name="EvictionPolicyConfig">
       <config>
       <attribute name="wakeUpIntervalSeconds">5</attribute>
       <!-- Cache wide default -->
       <region name="/_default_">
       <attribute name="maxNodes">5000</attribute>
       <attribute name="timeToLiveSeconds">5</attribute>
       </region>
       <region name="/org/jboss/data">
       <attribute name="maxNodes">5000</attribute>
       <attribute name="timeToLiveSeconds">1000</attribute>
       </region>
       <region name="/test">
       <attribute name="maxNodes">5000</attribute>
       <attribute name="timeToLiveSeconds">3</attribute>
       <attrubute name="maxAgeSeconds">0</attrubute>>
       </region>
       </config>
       </attribute>
      
       <!--
       <attribute name="CacheLoaderConfiguration">
       <config>
       <passivation>true</passivation>
       <preload></preload>
       <cacheloader>
       <class>org.jboss.cache.loader.JDBCCacheLoader</class>
      
       <properties>
       cache.jdbc.table.name=jbosscache
       cache.jdbc.table.create=true
       cache.jdbc.table.drop=true
       cache.jdbc.table.primarykey=jbosscache_pk
       cache.jdbc.fqn.column=fqn
       cache.jdbc.fqn.type=char(255)
       cache.jdbc.node.column=node
       cache.jdbc.node.type=blob
       cache.jdbc.parent.column=parent
       cache.jdbc.driver=com.mysql.jdbc.Driver
       cache.jdbc.url=jdbc:mysql://localhost/Discuz
       cache.jdbc.user=root
       cache.jdbc.password=
       </properties>
       <async>false</async>
       <fetchPersistentState>false</fetchPersistentState>
       <ignoreModifications>false</ignoreModifications>
      
       <purgeOnStartup>false</purgeOnStartup>
       </cacheloader>
       </config>
      </attribute>
       -->
      
      
       <attribute name="CacheLoaderConfiguration">
       <config>
       <passivation>true</passivation>
      
       <shared>false</shared>
      
       <cacheloader>
       <class>org.jboss.cache.loader.bdbje.BdbjeCacheLoader</class>
       <properties>
       location=c:/tmp/filetore1
       </properties>
       <async>false</async>
      
       <fetchPersistentState>false</fetchPersistentState>
       <ignoreModifications>false</ignoreModifications>
       <purgeOnStartup>false</purgeOnStartup>
       </cacheloader>
      
       </config>
       </attribute>
      
       </mbean>
      
      
      </server>