提交 ef776d02 authored 作者: Thomas Mueller's avatar Thomas Mueller

LIRS cache: bugfix for very large cache sizes.

上级 0cbf67a1
......@@ -776,10 +776,10 @@ public class CacheLongKeyLIRS<V> {
* @param newCold a new cold entry
*/
private void evict(Entry<V> newCold) {
// ensure there are not too many hot entries:
// right shift of 5 is division by 32, that means if there are less
// than 1/32 (3.125%) cold entries, a new hot entry needs to become cold
while (queueSize < (mapSize >>> 5)) {
// 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 new hot entry needs to become cold
while (queueSize <= (mapSize >>> 5)) {
convertOldestHotToCold();
}
if (stackSize > 0) {
......
......@@ -724,10 +724,10 @@ public class CacheLIRS<K, V> extends AbstractMap<K, V> {
* @param newCold a new cold entry
*/
private void evict(Entry<K, V> newCold) {
// ensure there are not too many hot entries:
// right shift of 5 is division by 32, that means if there are less
// than 1/32 (3.125%) cold entries, a new hot entry needs to become cold
while (queueSize < (mapSize >>> 5)) {
// 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 new hot entry needs to become cold
while (queueSize <= (mapSize >>> 5)) {
convertOldestHotToCold();
}
if (stackSize > 0) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论