asmuts      02/01/28 22:12:58

  Modified:    src/java/org/apache/stratum/jcs/auxiliary/remote
                        RemoteCache.java
               src/java/org/apache/stratum/jcs/engine/memory/lru
                        LRUMemoryCache.java
               src/java/org/apache/stratum/jcs/auxiliary/disk/jisp
                        JISPKey.java JISPCache.java
               src/java/org/apache/stratum/jcs/engine CacheElement.java
               src/java/org/apache/stratum/jcs/engine/control Cache.java
  Log:
  fixed compareTo Jisp problem, the result is slow as hell.
  
  chunked a group to disk in the LRUMemoryCache.
  
  Revision  Changes    Path
  1.6       +1 -1      
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/remote/RemoteCache.java
  
  Index: RemoteCache.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/remote/RemoteCache.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- RemoteCache.java  21 Jan 2002 22:38:53 -0000      1.5
  +++ RemoteCache.java  29 Jan 2002 06:12:57 -0000      1.6
  @@ -34,7 +34,7 @@
       //true;
       Logger log;
       private static int numCreated = 0;
  -    private static boolean debug = true;
  +    private static boolean debug = false;//true;
       private static boolean debugR = false;
       private static boolean debugPut = false;
   
  
  
  
  1.4       +48 -19    
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/memory/lru/LRUMemoryCache.java
  
  Index: LRUMemoryCache.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/memory/lru/LRUMemoryCache.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- LRUMemoryCache.java       15 Jan 2002 21:33:35 -0000      1.3
  +++ LRUMemoryCache.java       29 Jan 2002 06:12:57 -0000      1.4
  @@ -28,7 +28,17 @@
   
   /////////////////////////////////////////////////////
   /**
  - *  Description of the Class
  + *  A fast reference management system. The least recently used items move tot
  + *  he end of the list and get spooled to disk if the cache hub is configured to
  + *  use a disk cache.
  + *
  + *  Most of the cache bottelnecks ar ein IO. There are no io bottlenecks here,
  + *  it's all about processing power.  Even though there are only a few adjustments
  + *  necessary to maintain the double linked list, we might want to find a more
  + *  efficient memory manager for large cache regions.  The LRUMemoryCache is most
  + *  efficeint when the first element is selected.  The smaller teh region, the
  + *  better the chance that this will be the case.  < .04 ms per put, p3 866,
  + *  1/10 of that per get
    *
    *@author     asmuts
    *@created    January 15, 2002
  @@ -37,7 +47,6 @@
   {
   
       private final static boolean debugcmd = false;
  -    //true;
       // removal
       private final static boolean debugR = false;
       //true;
  @@ -80,6 +89,9 @@
       // status
       private int status = this.STATUS_ERROR;
   
  +    // make configurable
  +    private int chunkSize = 5;
  +
   
       ////////////////////////////////////////////////////////////////////
       // for reflection
  @@ -168,10 +180,11 @@
               removeNode( old );
           }
   
  +        // save a microsecond on the second call.
  +        int size = map.size();
           // need to spool at a certain percentage synchronously
  -        if ( map.size() < this.cattr.getMaxObjects() )
  +        if ( size < this.cattr.getMaxObjects() )
           {
  -
               return;
           }
           else
  @@ -187,9 +200,34 @@
               try
               {
   
  -                // Might want to rename this "overflow" incase the hub
  -                // wants to do somethign else.
  -                hub.spoolToDisk( last.ce );
  +                // PUSH 5 TO DISK TO MINIMIZE THE TYPICAL
  +                int chunkSizeCorrected = Math.min( size, chunkSize );
  +
  +                if ( debugcmd )
  +                {
  +                    p( "update: About to spool to disk cache, map.size() = " + size 
+ ", this.cattr.getMaxObjects() = " + this.cattr.getMaxObjects() + ", 
chunkSizeCorrected = " + chunkSizeCorrected );
  +                }
  +
  +                // The spool will put them in a disk event queue, so there is no
  +                // need to pre-queue the queuing.  This would be a bit wasteful
  +                // and wouldn't save much time in this synchronous call.
  +                for ( int i = 0; i < chunkSizeCorrected; i++ )
  +                {
  +                    // Might want to rename this "overflow" incase the hub
  +                    // wants to do something else.
  +                    hub.spoolToDisk( last.ce );
  +                    map.remove( last.ce.getKey() );
  +                    removeNode( last );
  +                }
  +
  +                if ( debugcmd )
  +                {
  +                    p( "update: After spool, put " + last.ce.getKey() + " on disk 
cache, map.size() = " + size + ", this.cattr.getMaxObjects() = " + 
this.cattr.getMaxObjects() + ", chunkSizeCorrected = " + chunkSizeCorrected );
  +                }
  +                if ( log.logLevel >= log.DEBUG )
  +                {
  +                    log.debug( "update: After spool, put " + last.ce.getKey() + " 
on disk cache, map.size() = " + size + ", this.cattr.getMaxObjects() = " + 
this.cattr.getMaxObjects() + ", chunkSizeCorrected = " + chunkSizeCorrected );
  +                }
   
               }
               catch ( Exception ex )
  @@ -199,19 +237,8 @@
                   throw new IllegalStateException( ex.getMessage() );
               }
   
  -            if ( log.logLevel >= log.DEBUG )
  -            {
  -                log.debug( "update: Request to put " + last.ce.getKey() + " on disk 
cache" );
  -            }
           }
   
  -        // if no disk cache is configured, these elements are lost
  -        if ( map.size() > this.cattr.getMaxObjects() )
  -        {
  -            // Remove the last item from memory.
  -            map.remove( last.ce.getKey() );
  -            removeNode( last );
  -        }
       }
       // end update
   
  @@ -427,7 +454,9 @@
        *@exception  IOException  Description of the Exception
        */
       public void dispose()
  -        throws IOException { }
  +        throws IOException
  +    {
  +    }
   
   
       /**
  
  
  
  1.4       +34 -3     
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/disk/jisp/JISPKey.java
  
  Index: JISPKey.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/disk/jisp/JISPKey.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JISPKey.java      15 Jan 2002 21:33:30 -0000      1.3
  +++ JISPKey.java      29 Jan 2002 06:12:57 -0000      1.4
  @@ -23,6 +23,9 @@
   public class JISPKey extends KeyObject
   {
   
  +    // for simple debugging
  +    private final static boolean debug = false;//true;
  +
       //
       // working storage
       //
  @@ -64,8 +67,13 @@
   
           if ( key instanceof JISPKey )
           {
  -            int orig = ( ( JISPKey ) key ).m_key.hashCode();
  +            //int orig = ( ( JISPKey ) key ).m_key.hashCode();
  +            int orig = m_key.hashCode();
               int test = key.hashCode();
  +            if ( debug )
  +            {
  +                p( "orig = " + orig + ", test = " + test );
  +            }
               int cv = test - orig;
               if ( cv == 0 )
               {
  @@ -164,7 +172,14 @@
       {
           if ( ( obj != null ) && ( obj instanceof JISPKey ) )
           {
  -            return ( m_key.equals( ( ( JISPKey ) obj ).m_key ) );
  +            int orig = m_key.hashCode();
  +            int test = ( ( JISPKey ) obj ).m_key.hashCode();
  +            if ( debug )
  +            {
  +                p( "orig = " + orig + ", test = " + test );
  +            }
  +            return ( orig == test );
  +            //return ( m_key.equals( ( ( JISPKey ) obj ).m_key ) );
           }
           else
           {
  @@ -180,7 +195,23 @@
        */
       public int hashCode()
       {
  -        return m_key.hashCode();
  +        int hash = m_key.hashCode();
  +        if ( debug )
  +        {
  +            p( "hash = " + hash );
  +        }
  +        return hash;
           // new Integer(m_key).hashCode();
       }
  +
  +    /**
  +     *  Easy debugging printing
  +     *
  +     *@param  s  Stirng to print
  +     */
  +    public void p( String s )
  +    {
  +        System.out.println( "JISPKey: " + s );
  +    }
  +
   }
  
  
  
  1.11      +13 -10    
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/disk/jisp/JISPCache.java
  
  Index: JISPCache.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/disk/jisp/JISPCache.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- JISPCache.java    19 Jan 2002 06:27:12 -0000      1.10
  +++ JISPCache.java    29 Jan 2002 06:12:57 -0000      1.11
  @@ -77,7 +77,7 @@
   
   ////////////////////////////////////////////////////////////////////////
   /**
  - *  JISP disk cache implementation.
  + *  JISP disk cache implementation.  Slow as hell with this type of key.
    *
    *@author     <a href="mailto:[EMAIL PROTECTED]";>Aaron Smuts</a>
    *@created    January 15, 2002
  @@ -91,14 +91,10 @@
       private int numInstances = 0;
   
       // trivial debugging that should be removed by the compiler
  -    private final static boolean debug = false;
  -    //true;
  -    private final static boolean debugR = false;
  -    //true;
  -    private final static boolean debugPut = false;
  -    //true;
  -    private final static boolean debugGet = false;
  -    //true;
  +    private final static boolean debug = false;//true;
  +    private final static boolean debugR = false;//true;
  +    private final static boolean debugPut = false;//true;//false;
  +    private final static boolean debugGet = false;//true;//false;
   
       private String cacheName;
   
  @@ -218,6 +214,7 @@
       }
       // end constructor
   
  +    //////////////////////////////////////////////////////////////////
       /**
        *  SETUP TABLE FOR CACHE
        */
  @@ -386,7 +383,7 @@
           buffer.purgatory.remove( ce.getKey() );
           if ( debug )
           {
  -            p( "putting " + ce.getKey() + " on disk, removing from purgatory" );
  +            p( "\n putting " + ce.getKey() + " on disk, removing from purgatory" );
           }
   
           if ( debug )
  @@ -487,6 +484,12 @@
           {
               return null;
           }
  +
  +        if ( debugGet )
  +        {
  +            p( " " + key + ", val = " + obj.getVal() );
  +        }
  +
           if ( container )
           {
               return ( Serializable ) obj;
  
  
  
  1.4       +6 -0      
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/CacheElement.java
  
  Index: CacheElement.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/CacheElement.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- CacheElement.java 15 Jan 2002 21:33:33 -0000      1.3
  +++ CacheElement.java 29 Jan 2002 06:12:58 -0000      1.4
  @@ -144,6 +144,12 @@
           return this.createTime;
       }
   
  +    ///////////////////////////////////////////////////////////
  +    public int hashCode()
  +    {
  +        return key.hashCode();
  +    }
  +
   
       ///////////////////////////////////////////////////
       /**
  
  
  
  1.10      +1 -1      
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/control/Cache.java
  
  Index: Cache.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/control/Cache.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Cache.java        19 Jan 2002 06:27:13 -0000      1.9
  +++ Cache.java        29 Jan 2002 06:12:58 -0000      1.10
  @@ -449,7 +449,7 @@
                       p( "lateralcache in aux list" );
                       p( "cattr " + cacheAttr.getUseLateral() );
                   }
  -                if ( cacheAttr.getUseLateral() && ce.getAttributes().IS_LATERAL  && 
updateRemoteCache )
  +                if ( cacheAttr.getUseLateral() && ce.getAttributes().IS_LATERAL && 
updateRemoteCache )
                   {
   
                       // later if we want a multicast, possibly delete abnormal 
broadcaster
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to