lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hoss...@apache.org
Subject svn commit: r949476 - in /lucene/solr/branches/branch-1.4: ./ CHANGES.txt src/common/org/apache/solr/common/util/ConcurrentLRUCache.java src/java/org/apache/solr/search/FastLRUCache.java
Date Sun, 30 May 2010 04:53:01 GMT
Author: hossman
Date: Sun May 30 04:53:00 2010
New Revision: 949476

URL: http://svn.apache.org/viewvc?rev=949476&view=rev
Log:
merging r919871 from solr/branches/branch-1.5-dev for SOLR-1798

Modified:
    lucene/solr/branches/branch-1.4/   (props changed)
    lucene/solr/branches/branch-1.4/CHANGES.txt
    lucene/solr/branches/branch-1.4/src/common/org/apache/solr/common/util/ConcurrentLRUCache.java
    lucene/solr/branches/branch-1.4/src/java/org/apache/solr/search/FastLRUCache.java

Propchange: lucene/solr/branches/branch-1.4/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun May 30 04:53:00 2010
@@ -1 +1 @@
-/lucene/solr/trunk:881642,881906,883566,891596,891889,903271,911245,925898
+/lucene/solr/trunk:881642,881906,883566,891596,891889,903271,911245,919871,925898

Modified: lucene/solr/branches/branch-1.4/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/solr/branches/branch-1.4/CHANGES.txt?rev=949476&r1=949475&r2=949476&view=diff
==============================================================================
--- lucene/solr/branches/branch-1.4/CHANGES.txt (original)
+++ lucene/solr/branches/branch-1.4/CHANGES.txt Sun May 30 04:53:00 2010
@@ -74,6 +74,9 @@ Bug Fixes
 * SOLR-1797: fix ConcurrentModificationException and potential memory
   leaks in ResourceLoader. (yonik)
 
+* SOLR-1798: Small memory leak (~100 bytes) in fastLRUCache for every
+  commit. (yonik)
+
 ================== Release 1.4.0 ==================
 Release Date:  See http://lucene.apache.org/solr for the official release date.
 

Modified: lucene/solr/branches/branch-1.4/src/common/org/apache/solr/common/util/ConcurrentLRUCache.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/branch-1.4/src/common/org/apache/solr/common/util/ConcurrentLRUCache.java?rev=949476&r1=949475&r2=949476&view=diff
==============================================================================
--- lucene/solr/branches/branch-1.4/src/common/org/apache/solr/common/util/ConcurrentLRUCache.java
(original)
+++ lucene/solr/branches/branch-1.4/src/common/org/apache/solr/common/util/ConcurrentLRUCache.java
Sun May 30 04:53:00 2010
@@ -384,7 +384,7 @@ public class ConcurrentLRUCache<K,V> {
     CacheEntry<K,V> o = map.remove(key);
     if (o == null) return;
     stats.size.decrementAndGet();
-    stats.evictionCounter++;
+    stats.evictionCounter.incrementAndGet();
     if(evictionListener != null) evictionListener.evictedEntry(o.key,o.value);
   }
 
@@ -518,7 +518,7 @@ public class ConcurrentLRUCache<K,V> {
             nonLivePutCounter = new AtomicLong(0),
             missCounter = new AtomicLong();
     private final AtomicInteger size = new AtomicInteger();
-    private long evictionCounter = 0;
+    private AtomicLong evictionCounter = new AtomicLong();
 
     public long getCumulativeLookups() {
       return (accessCounter.get() - putCounter.get() - nonLivePutCounter.get()) + missCounter.get();
@@ -533,7 +533,7 @@ public class ConcurrentLRUCache<K,V> {
     }
 
     public long getCumulativeEvictions() {
-      return evictionCounter;
+      return evictionCounter.get();
     }
 
     public int getCurrentSize() {
@@ -547,6 +547,15 @@ public class ConcurrentLRUCache<K,V> {
     public long getCumulativeMisses() {
       return missCounter.get();
     }
+
+    public void add(Stats other) {
+      accessCounter.addAndGet(other.accessCounter.get());
+      putCounter.addAndGet(other.putCounter.get());
+      nonLivePutCounter.addAndGet(other.nonLivePutCounter.get());
+      missCounter.addAndGet(other.missCounter.get());
+      evictionCounter.addAndGet(other.evictionCounter.get());
+      size.set(Math.max(size.get(), other.size.get()));
+    }
   }
 
   public static interface EvictionListener<K,V>{

Modified: lucene/solr/branches/branch-1.4/src/java/org/apache/solr/search/FastLRUCache.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/branch-1.4/src/java/org/apache/solr/search/FastLRUCache.java?rev=949476&r1=949475&r2=949476&view=diff
==============================================================================
--- lucene/solr/branches/branch-1.4/src/java/org/apache/solr/search/FastLRUCache.java (original)
+++ lucene/solr/branches/branch-1.4/src/java/org/apache/solr/search/FastLRUCache.java Sun
May 30 04:53:00 2010
@@ -45,7 +45,8 @@ import java.util.concurrent.CopyOnWriteA
  */
 public class FastLRUCache implements SolrCache {
 
-  private List<ConcurrentLRUCache.Stats> cumulativeStats;
+  // contains the statistics objects for all open caches of the same type
+  private List<ConcurrentLRUCache.Stats> statsList;
 
   private long warmupTime = 0;
 
@@ -104,16 +105,18 @@ public class FastLRUCache implements Sol
     cache = new ConcurrentLRUCache(limit, minLimit, acceptableLimit, initialSize, newThread,
false, null);
     cache.setAlive(false);
 
-    if (persistence == null) {
+    statsList = (List<ConcurrentLRUCache.Stats>) persistence;
+    if (statsList == null) {
       // must be the first time a cache of this type is being created
       // Use a CopyOnWriteArrayList since puts are very rare and iteration may be a frequent
operation
       // because it is used in getStatistics()
-      persistence = new CopyOnWriteArrayList<ConcurrentLRUCache.Stats>();
-    }
+      statsList = new CopyOnWriteArrayList<ConcurrentLRUCache.Stats>();
 
-    cumulativeStats = (List<ConcurrentLRUCache.Stats>) persistence;
-    cumulativeStats.add(cache.getStats());
-    return cumulativeStats;
+      // the first entry will be for cumulative stats of caches that have been closed.
+      statsList.add(new ConcurrentLRUCache.Stats());
+    }
+    statsList.add(cache.getStats());
+    return statsList;
   }
 
   public String name() {
@@ -131,7 +134,6 @@ public class FastLRUCache implements Sol
 
   public Object get(Object key) {
     return cache.get(key);
-
   }
 
   public void clear() {
@@ -177,6 +179,9 @@ public class FastLRUCache implements Sol
 
 
   public void close() {
+    // add the stats to the cumulative stats object (the first in the statsList)
+    statsList.get(0).add(cache.getStats());
+    statsList.remove(cache.getStats());
     cache.destroy();
   }
 
@@ -243,7 +248,7 @@ public class FastLRUCache implements Sol
     long cevictions = 0;
 
     // NOTE: It is safe to iterate on a CopyOnWriteArrayList
-    for (ConcurrentLRUCache.Stats statistiscs : cumulativeStats) {
+    for (ConcurrentLRUCache.Stats statistiscs : statsList) {
       clookups += statistiscs.getCumulativeLookups();
       chits += statistiscs.getCumulativeHits();
       cinserts += statistiscs.getCumulativePuts();



Mime
View raw message