提交 56936506 authored 作者: Andrei Tokar's avatar Andrei Tokar

limit the size of a non-resident queue

上级 6e9f7dab
...@@ -931,8 +931,13 @@ public class CacheLongKeyLIRS<V> { ...@@ -931,8 +931,13 @@ public class CacheLongKeyLIRS<V> {
void trimNonResidentQueue() { void trimNonResidentQueue() {
Entry<V> e; Entry<V> e;
int maxQueue2Size = nonResidentQueueSize * (mapSize - queue2Size); int maxQueue2Size = 4 * nonResidentQueueSize * (mapSize - queue2Size);
if (maxQueue2Size >= 0) { while (queue2Size > maxQueue2Size) {
e = queue2.queuePrev;
int hash = getHash(e.key);
remove(e.key, hash);
}
maxQueue2Size >>= 2;
while (queue2Size > maxQueue2Size) { while (queue2Size > maxQueue2Size) {
e = queue2.queuePrev; e = queue2.queuePrev;
WeakReference<V> reference = e.reference; WeakReference<V> reference = e.reference;
...@@ -943,7 +948,6 @@ public class CacheLongKeyLIRS<V> { ...@@ -943,7 +948,6 @@ public class CacheLongKeyLIRS<V> {
remove(e.key, hash); remove(e.key, hash);
} }
} }
}
private void convertOldestHotToCold() { private void convertOldestHotToCold() {
// the last entry of the stack is known to be hot // the last entry of the stack is known to be hot
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论