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

TestCrashAPI: filter NPE

上级 8a5b3ca8
......@@ -485,6 +485,14 @@ public class CacheLongKeyLIRS<V> {
}
}
public void trimNonResidentQueue() {
for (Segment<V> s : segments) {
synchronized (s) {
s.trimNonResidentQueue();
}
}
}
/**
* A cache segment
*
......@@ -905,7 +913,7 @@ public class CacheLongKeyLIRS<V> {
// ensure there are not too many hot entries: right shift of 5 is
// division by 32, that means if there are only 1/32 (3.125%) or
// less cold entries, a hot entry needs to become cold
while (queueSize <= (mapSize >>> 5) && stackSize > 0) {
while (queueSize <= ((mapSize - queue2Size) >>> 5) && stackSize > 0) {
convertOldestHotToCold();
}
// the oldest resident cold entries become non-resident
......@@ -917,6 +925,12 @@ public class CacheLongKeyLIRS<V> {
e.value = null;
addToQueue(queue2, e);
// the size of the non-resident-cold entries needs to be limited
trimNonResidentQueue();
}
}
private void trimNonResidentQueue() {
Entry<V> e;
int maxQueue2Size = nonResidentQueueSize * (mapSize - queue2Size);
if (maxQueue2Size >= 0) {
while (queue2Size > maxQueue2Size) {
......@@ -930,7 +944,6 @@ public class CacheLongKeyLIRS<V> {
}
}
}
}
private void convertOldestHotToCold() {
// the last entry of the stack is known to be hot
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论