diff src/org/dancres/blitz/entry/SleeveCache.java @ 22:b7e52953b7a6

Add some cache/memory statistics to help spot potential exhaustion and other tuning issues.
author Dan Creswell <dan.creswell@gmail.com>
date Fri, 28 Aug 2009 17:23:33 +0100
parents 8417eaebf5ab
children
line wrap: on
line diff
--- a/src/org/dancres/blitz/entry/SleeveCache.java	Sat Aug 22 23:28:55 2009 +0100
+++ b/src/org/dancres/blitz/entry/SleeveCache.java	Fri Aug 28 17:23:33 2009 +0100
@@ -14,7 +14,7 @@
 import org.dancres.blitz.Logging;
 import org.dancres.blitz.stats.StatGenerator;
 import org.dancres.blitz.stats.Stat;
-import org.dancres.blitz.stats.SearchStat;
+import org.dancres.blitz.stats.StoreStat;
 import org.dancres.blitz.stats.StatsBoard;
 
 import org.dancres.blitz.oid.OID;
@@ -73,15 +73,13 @@
     }
 
     private final ArcCache[] theStoreCaches;
+    private final CacheSize theCacheSize;
     private final int theNumPartitions;
     private final int thePartitionsMask;
 
     private Storage theStore;
-
     private CountersImpl theCounters;
-
     private EntryConstraints theConstraints;
-
     private CacheIndexer theIndexer;
 
     private long theId = StatGenerator.UNSET_ID;
@@ -145,16 +143,16 @@
             throw myIOE;
         }
         
-        CacheSize myCacheSize = (CacheSize) theConstraints.get(CacheSize.class);
+        theCacheSize = (CacheSize) theConstraints.get(CacheSize.class);
 
         int myNumPartitions;
         int myEntriesPerCache;
 
         if (DESIRED_ENTRIES_PER_PARTITION == -1) {
             myNumPartitions = 1;
-            myEntriesPerCache = myCacheSize.getSize();
+            myEntriesPerCache = theCacheSize.getSize();
         } else {
-            myNumPartitions = (myCacheSize.getSize() / DESIRED_ENTRIES_PER_PARTITION);
+            myNumPartitions = (theCacheSize.getSize() / DESIRED_ENTRIES_PER_PARTITION);
             myEntriesPerCache = DESIRED_ENTRIES_PER_PARTITION;
         }
 
@@ -167,7 +165,7 @@
         thePartitionsMask = theNumPartitions - 1;
         
         theLogger.log(Level.INFO, aStore.getType() + " cache size = "
-                      + myCacheSize.getSize() + " partitions = " + theNumPartitions + 
+                      + theCacheSize.getSize() + " partitions = " + theNumPartitions +
                       " mask = " + Integer.toHexString(thePartitionsMask) + " partition size = " + myEntriesPerCache);
 
         theStoreCaches = new ArcCache[theNumPartitions];
@@ -214,8 +212,13 @@
             myDeld[i] = theTrackers[i].getDeld();
         }
 
-        return new SearchStat(theId, theStore.getType(), myTitles,
-            myMisses, myDeld);
+        int myActiveCache = 0;
+
+        for (int i = 0; i < theStoreCaches.length; i++)
+            myActiveCache += theStoreCaches[i].getActiveSize();
+
+        return new StoreStat(theId, theStore.getType(), myTitles,
+            myMisses, myDeld, myActiveCache, theCacheSize.getSize());
     }
 
     private int getPartition(CacheBlockDescriptor aCBD) {