* Divide swappability of objects by refcount
* it should be possible to give the vm-max-memory option in megabyte, gigabyte, ..., just using 2GB, 100MB, and so forth.
* Try to understand what can be moved into I/O threads that currently is instead handled by the main thread. For instance swapping file table scannig to find contiguous page could be a potential candidate (but I'm not convinced it's a good idea, better to improve the algorithm, for instance double the fast forward at every step?).
+* EXISTS should avoid loading the object if possible without too make the code too specialized.
+* vm-min-age <seconds> option
* Hashes (HSET, HGET, HDEL, HEXISTS, HLEN, ...).
int cronloops; /* number of times the cron function run */
list *objfreelist; /* A list of freed objects to avoid malloc() */
time_t lastsave; /* Unix time of last save succeeede */
- size_t usedmemory; /* Used memory in megabytes */
/* Fields used only for stats */
time_t stat_starttime; /* server start time */
long long stat_numcommands; /* number of processed commands */
* To access a global var is faster than calling time(NULL) */
server.unixtime = time(NULL);
- /* Update the global state with the amount of used memory */
- server.usedmemory = zmalloc_used_memory();
-
/* Show some info about non-empty databases */
for (j = 0; j < server.dbnum; j++) {
long long size, used, vkeys;
redisLog(REDIS_VERBOSE,"%d clients connected (%d slaves), %zu bytes in use, %d shared objects",
listLength(server.clients)-listLength(server.slaves),
listLength(server.slaves),
- server.usedmemory,
+ zmalloc_used_memory(),
dictSize(server.sharingpool));
}
server.bgrewritebuf = sdsempty();
server.lastsave = time(NULL);
server.dirty = 0;
- server.usedmemory = 0;
server.stat_numcommands = 0;
server.stat_numconnections = 0;
server.stat_starttime = time(NULL);
sprintf(s,"%.2fM",d);
} else if (n < (1024LL*1024*1024*1024)) {
d = (double)n/(1024LL*1024*1024);
- sprintf(s,"%.2fM",d);
+ sprintf(s,"%.2fG",d);
}
}
int j;
char hmem[64];
- bytesToHuman(hmem,server.usedmemory);
+ bytesToHuman(hmem,zmalloc_used_memory());
info = sdscatprintf(sdsempty(),
"redis_version:%s\r\n"
"arch_bits:%s\r\n"
listLength(server.clients)-listLength(server.slaves),
listLength(server.slaves),
server.blockedclients,
- server.usedmemory,
+ zmalloc_used_memory(),
hmem,
server.dirty,
server.bgsavechildpid != -1,
for (j = 0; j < server.dbnum; j++) {
redisDb *db = server.db+j;
+ /* Why maxtries is set to 100?
+ * Because this way (usually) we'll find 1 object even if just 1% - 2%
+ * are swappable objects */
int maxtries = 100;
if (dictSize(db->dict) == 0) continue;