summaryrefslogtreecommitdiff
path: root/src/expire.c
diff options
context:
space:
mode:
authoryoav-steinberg <yoav@monfort.co.il>2021-08-05 08:25:58 +0300
committerGitHub <noreply@github.com>2021-08-05 08:25:58 +0300
commit5e908a290ccbe9c4a7bea9356faf3b837df62793 (patch)
treeee8c2008ef1c18653203245dd40d3befb2cd364f /src/expire.c
parent1c59567a7fe207997eef6197eefa7d508d7fbf9f (diff)
downloadredis-5e908a290ccbe9c4a7bea9356faf3b837df62793.tar.gz
dict struct memory optimizations (#9228)
Reduce dict struct memory overhead on 64bit dict size goes down from jemalloc's 96 byte bin to its 56 byte bin. summary of changes: - Remove `privdata` from callbacks and dict creation. (this affects many files, see "Interface change" below). - Meld `dictht` struct into the `dict` struct to eliminate struct padding. (this affects just dict.c and defrag.c) - Eliminate the `sizemask` field, can be calculated from size when needed. - Convert the `size` field into `size_exp` (exponent), utilizes one byte instead of 8. Interface change: pass dict pointer to dict type call back functions. This is instead of passing the removed privdata field. In the future if we'd like to have private data in the callbacks we can extract it from the dict type. We can extend dictType to include a custom dict struct allocator and use it to allocate more data at the end of the dict struct. This data can then be used to store private data later acccessed by the callbacks.
Diffstat (limited to 'src/expire.c')
-rw-r--r--src/expire.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/expire.c b/src/expire.c
index 2dcdddaf6..858c13549 100644
--- a/src/expire.c
+++ b/src/expire.c
@@ -258,8 +258,8 @@ void activeExpireCycle(int type) {
if (table == 1 && !dictIsRehashing(db->expires)) break;
unsigned long idx = db->expires_cursor;
- idx &= db->expires->ht[table].sizemask;
- dictEntry *de = db->expires->ht[table].table[idx];
+ idx &= DICTHT_SIZE_MASK(db->expires->ht_size_exp[table]);
+ dictEntry *de = db->expires->ht_table[table][idx];
long long ttl;
/* Scan the current bucket of the current table. */
@@ -439,7 +439,7 @@ void rememberSlaveKeyWithExpire(redisDb *db, robj *key) {
NULL, /* val destructor */
NULL /* allow to expand */
};
- slaveKeysWithExpire = dictCreate(&dt,NULL);
+ slaveKeysWithExpire = dictCreate(&dt);
}
if (db->id > 63) return;