Specify LRU resolution in milliseconds.
This commit is contained in:
parent
a8127d9fcb
commit
2f5a67dbca
@ -292,7 +292,7 @@ void debugCommand(redisClient *c) {
|
|||||||
addReplyStatusFormat(c,
|
addReplyStatusFormat(c,
|
||||||
"Value at:%p refcount:%d "
|
"Value at:%p refcount:%d "
|
||||||
"encoding:%s serializedlength:%lld "
|
"encoding:%s serializedlength:%lld "
|
||||||
"lru:%d lru_seconds_idle:%lu",
|
"lru:%d lru_seconds_idle:%llu",
|
||||||
(void*)val, val->refcount,
|
(void*)val, val->refcount,
|
||||||
strenc, (long long) rdbSavedObjectLen(val),
|
strenc, (long long) rdbSavedObjectLen(val),
|
||||||
val->lru, estimateObjectIdleTime(val));
|
val->lru, estimateObjectIdleTime(val));
|
||||||
|
@ -650,7 +650,7 @@ char *strEncoding(int encoding) {
|
|||||||
|
|
||||||
/* Given an object returns the min number of seconds the object was never
|
/* Given an object returns the min number of seconds the object was never
|
||||||
* requested, using an approximated LRU algorithm. */
|
* requested, using an approximated LRU algorithm. */
|
||||||
unsigned long estimateObjectIdleTime(robj *o) {
|
unsigned long long estimateObjectIdleTime(robj *o) {
|
||||||
if (server.lruclock >= o->lru) {
|
if (server.lruclock >= o->lru) {
|
||||||
return (server.lruclock - o->lru) * REDIS_LRU_CLOCK_RESOLUTION;
|
return (server.lruclock - o->lru) * REDIS_LRU_CLOCK_RESOLUTION;
|
||||||
} else {
|
} else {
|
||||||
|
@ -844,11 +844,10 @@ void activeExpireCycle(int type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void updateLRUClock(void) {
|
void updateLRUClock(void) {
|
||||||
server.lruclock = (server.unixtime/REDIS_LRU_CLOCK_RESOLUTION) &
|
server.lruclock = (mstime()/REDIS_LRU_CLOCK_RESOLUTION) &
|
||||||
REDIS_LRU_CLOCK_MAX;
|
REDIS_LRU_CLOCK_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Add a sample to the operations per second array of samples. */
|
/* Add a sample to the operations per second array of samples. */
|
||||||
void trackOperationsPerSecond(void) {
|
void trackOperationsPerSecond(void) {
|
||||||
long long t = mstime() - server.ops_sec_last_sample_time;
|
long long t = mstime() - server.ops_sec_last_sample_time;
|
||||||
|
@ -384,7 +384,7 @@ typedef long long mstime_t; /* millisecond time type. */
|
|||||||
/* The actual Redis Object */
|
/* The actual Redis Object */
|
||||||
#define REDIS_LRU_BITS 22
|
#define REDIS_LRU_BITS 22
|
||||||
#define REDIS_LRU_CLOCK_MAX ((1<<REDIS_LRU_BITS)-1) /* Max value of obj->lru */
|
#define REDIS_LRU_CLOCK_MAX ((1<<REDIS_LRU_BITS)-1) /* Max value of obj->lru */
|
||||||
#define REDIS_LRU_CLOCK_RESOLUTION 10 /* LRU clock resolution in seconds */
|
#define REDIS_LRU_CLOCK_RESOLUTION 10000 /* LRU clock resolution in ms */
|
||||||
typedef struct redisObject {
|
typedef struct redisObject {
|
||||||
unsigned type:4;
|
unsigned type:4;
|
||||||
unsigned notused:2; /* Not used */
|
unsigned notused:2; /* Not used */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user