You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by ho...@apache.org on 2010/05/30 06:15:52 UTC
svn commit: r949469 - in /lucene/solr/branches/branch-1.4: ./ CHANGES.txt
src/common/org/apache/solr/common/util/ConcurrentLRUCache.java
Author: hossman
Date: Sun May 30 04:15:51 2010
New Revision: 949469
URL: http://svn.apache.org/viewvc?rev=949469&view=rev
Log:
merging r881906 from solr/branches/branch-1.5-dev for SOLR-1572
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
Propchange: lucene/solr/branches/branch-1.4/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun May 30 04:15:51 2010
@@ -1 +1 @@
-/lucene/solr/trunk:881642
+/lucene/solr/trunk:881642,881906
Modified: lucene/solr/branches/branch-1.4/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/solr/branches/branch-1.4/CHANGES.txt?rev=949469&r1=949468&r2=949469&view=diff
==============================================================================
--- lucene/solr/branches/branch-1.4/CHANGES.txt (original)
+++ lucene/solr/branches/branch-1.4/CHANGES.txt Sun May 30 04:15:51 2010
@@ -52,7 +52,8 @@ Bug Fixes
to the original ValueSource.getValues(reader) so custom sources
will work. (yonik)
-
+* SOLR-1572: FastLRUCache correctly implemented the LRU policy only
+ for the first 2B accesses. (yonik)
================== Release 1.4.0 ==================
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=949469&r1=949468&r2=949469&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:15:51 2010
@@ -106,8 +106,11 @@ public class ConcurrentLRUCache<K,V> {
if (val == null) return null;
CacheEntry e = new CacheEntry(key, val, stats.accessCounter.incrementAndGet());
CacheEntry oldCacheEntry = map.put(key, e);
+ int currentSize;
if (oldCacheEntry == null) {
- stats.size.incrementAndGet();
+ currentSize = stats.size.incrementAndGet();
+ } else {
+ currentSize = stats.size.get();
}
if (islive) {
stats.putCounter.incrementAndGet();
@@ -125,7 +128,7 @@ public class ConcurrentLRUCache<K,V> {
//
// Thread safety note: isCleaning read is piggybacked (comes after) other volatile reads
// in this method.
- if (stats.size.get() > upperWaterMark && !isCleaning) {
+ if (currentSize > upperWaterMark && !isCleaning) {
if (newThreadForCleanup) {
new Thread() {
public void run() {
@@ -174,7 +177,7 @@ public class ConcurrentLRUCache<K,V> {
int numKept = 0;
long newestEntry = timeCurrent;
long newNewestEntry = -1;
- long newOldestEntry = Integer.MAX_VALUE;
+ long newOldestEntry = Long.MAX_VALUE;
int wantToKeep = lowerWaterMark;
int wantToRemove = sz - lowerWaterMark;
@@ -222,8 +225,8 @@ public class ConcurrentLRUCache<K,V> {
// over the values we collected, with updated min and max values.
while (sz - numRemoved > acceptableWaterMark && --numPasses>=0) {
- oldestEntry = newOldestEntry == Integer.MAX_VALUE ? oldestEntry : newOldestEntry;
- newOldestEntry = Integer.MAX_VALUE;
+ oldestEntry = newOldestEntry == Long.MAX_VALUE ? oldestEntry : newOldestEntry;
+ newOldestEntry = Long.MAX_VALUE;
newestEntry = newNewestEntry;
newNewestEntry = -1;
wantToKeep = lowerWaterMark - numKept;
@@ -270,8 +273,8 @@ public class ConcurrentLRUCache<K,V> {
// inserting into a priority queue
if (sz - numRemoved > acceptableWaterMark) {
- oldestEntry = newOldestEntry == Integer.MAX_VALUE ? oldestEntry : newOldestEntry;
- newOldestEntry = Integer.MAX_VALUE;
+ oldestEntry = newOldestEntry == Long.MAX_VALUE ? oldestEntry : newOldestEntry;
+ newOldestEntry = Long.MAX_VALUE;
newestEntry = newNewestEntry;
newNewestEntry = -1;
wantToKeep = lowerWaterMark - numKept;
@@ -338,7 +341,7 @@ public class ConcurrentLRUCache<K,V> {
// System.out.println("items removed:" + numRemoved + " numKept=" + numKept + " initialQueueSize="+ wantToRemove + " finalQueueSize=" + queue.size() + " sz-numRemoved=" + (sz-numRemoved));
}
- oldestEntry = newOldestEntry == Integer.MAX_VALUE ? oldestEntry : newOldestEntry;
+ oldestEntry = newOldestEntry == Long.MAX_VALUE ? oldestEntry : newOldestEntry;
this.oldestEntry = oldestEntry;
} finally {
isCleaning = false; // set before markAndSweep.unlock() for visibility