changeset 21:8417eaebf5ab

Fix partitioning to size caches properly
author Dan Creswell <dan.creswell@gmail.com>
date Sat, 22 Aug 2009 23:28:55 +0100
parents 66c7bfc3e89e
children b7e52953b7a6
files src/org/dancres/blitz/entry/SleeveCache.java
diffstat 1 files changed, 12 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/org/dancres/blitz/entry/SleeveCache.java	Sun Aug 16 15:26:33 2009 +0100
+++ b/src/org/dancres/blitz/entry/SleeveCache.java	Sat Aug 22 23:28:55 2009 +0100
@@ -63,8 +63,9 @@
                     ((Integer) ConfigurationFactory.getEntry("cacheEntriesPerPartition", int.class,
                     new Integer(128))).intValue();
 
-            theLogger.log(Level.SEVERE, "Loaded config: " + ((Integer) ConfigurationFactory.getEntry("cacheEntriesPerPartition", int.class,
-                    new Integer(128))).intValue());
+            theLogger.log(Level.SEVERE, "Loaded config: " +
+                    ((Integer) ConfigurationFactory.getEntry("cacheEntriesPerPartition", int.class,
+                    new Integer(32))).intValue());
             
         } catch (ConfigurationException aCE) {
             theLogger.log(Level.SEVERE, "Failed to source partition setup", aCE);
@@ -147,11 +148,15 @@
         CacheSize myCacheSize = (CacheSize) theConstraints.get(CacheSize.class);
 
         int myNumPartitions;
+        int myEntriesPerCache;
 
-        if (DESIRED_ENTRIES_PER_PARTITION == -1)
+        if (DESIRED_ENTRIES_PER_PARTITION == -1) {
             myNumPartitions = 1;
-        else
+            myEntriesPerCache = myCacheSize.getSize();
+        } else {
             myNumPartitions = (myCacheSize.getSize() / DESIRED_ENTRIES_PER_PARTITION);
+            myEntriesPerCache = DESIRED_ENTRIES_PER_PARTITION;
+        }
 
         // Find nearest power of 2 > or =
         //
@@ -162,12 +167,13 @@
         thePartitionsMask = theNumPartitions - 1;
         
         theLogger.log(Level.INFO, aStore.getType() + " cache size = "
-                      + myCacheSize.getSize() + " partitions = " + theNumPartitions + " mask = " + Integer.toHexString(thePartitionsMask));
+                      + myCacheSize.getSize() + " partitions = " + theNumPartitions + 
+                      " mask = " + Integer.toHexString(thePartitionsMask) + " partition size = " + myEntriesPerCache);
 
         theStoreCaches = new ArcCache[theNumPartitions];
 
         for (int i = 0; i < theNumPartitions; i++) {
-            theStoreCaches[i] = new ArcCache(aStore, theNumPartitions);
+            theStoreCaches[i] = new ArcCache(aStore, myEntriesPerCache);
 
             theIndexer = CacheIndexer.getIndexer(theStore.getType());