相关文章:Random notes on improving the Redis LRU algorithm
代码链接:https://github.com/antirez/redis/blob/unstable/src/evict.c
根据antirez的上述文章the value of the counter is halved
if it is an high value, or just decremented if it is a lower value
,但是在db.c
中,我只能在下面找到代码,而函数LFUDecrAndReturn
只是将经过时间的div减去计数器{ {1}}。我错过了什么吗?
lfu-decay-time
根据void updateLFU(robj *val) {
unsigned long counter = LFUDecrAndReturn(val);
counter = LFULogIncr(counter);
val->lru = (LFUGetTimeInMinutes()<<8) | counter;
}
中的注释,它显示为evict.c
,但是在After the pool is populated, the best key we have in the pool is expired. However note that we don't remove keys from the pool when they are deleted so the pool may contain keys that no longer exist.
中,一旦在逐出池中找到最佳条目,我就会发现freeMemoryIfNeeded(void)
等。 ..我可以理解,由于其他呼叫可以触发pool[k].key = NULL
(如果我错了,请指出错误,thx),因此可能会出现幻像键,但是为什么注释中会显示freeMemoryIfNeeded
?
为什么在分配逐出池时不使用链表而不是连续内存?在don't remove keys from the pool
中,一旦找到一个键的位置,就需要几次evictionPoolPopulate
调用,链表结构可以降低成本吗?
非常感谢!