# HG changeset patch # User Dan Creswell # Date 1250980135 -3600 # Node ID 8417eaebf5ab443e2fb43bb1839a12113a06e649 # Parent 66c7bfc3e89e09eac84d212c8286f3702f7738df Fix partitioning to size caches properly diff -r 66c7bfc3e89e -r 8417eaebf5ab src/org/dancres/blitz/entry/SleeveCache.java --- 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());