From 02fd76b97cbc5b8ad6f4c81c8538f02c76cbed46 Mon Sep 17 00:00:00 2001 From: sundb Date: Tue, 10 Aug 2021 14:18:49 +0800 Subject: Replace all usage of ziplist with listpack for t_hash (#8887) Part one of implementing #8702 (taking hashes first before other types) ## Description of the feature 1. Change ziplist encoded hash objects to listpack encoding. 2. Convert existing ziplists on RDB loading time. an O(n) operation. ## Rdb format changes 1. Add RDB_TYPE_HASH_LISTPACK rdb type. 2. Bump RDB_VERSION to 10 ## Interface changes 1. New `hash-max-listpack-entries` config is an alias for `hash-max-ziplist-entries` (same with `hash-max-listpack-value`) 2. OBJECT ENCODING will return `listpack` instead of `ziplist` ## Listpack improvements: 1. Support direct insert, replace integer element (rather than convert back and forth from string) 3. Add more listpack capabilities to match the ziplist ones (like `lpFind`, `lpRandomPairs` and such) 4. Optimize element length fetching, avoid multiple calculations 5. Use inline to avoid function call overhead. ## Tests 1. Add a new test to the RDB load time conversion 2. Adding the listpack unit tests. (based on the one in ziplist.c) 3. Add a few "corrupt payload: fuzzer findings" tests, and slightly modify existing ones. Co-authored-by: Oran Agra --- src/defrag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/defrag.c') diff --git a/src/defrag.c b/src/defrag.c index 5d18c9079..c804af370 100644 --- a/src/defrag.c +++ b/src/defrag.c @@ -864,7 +864,7 @@ long defragKey(redisDb *db, dictEntry *de) { serverPanic("Unknown sorted set encoding"); } } else if (ob->type == OBJ_HASH) { - if (ob->encoding == OBJ_ENCODING_ZIPLIST) { + if (ob->encoding == OBJ_ENCODING_LISTPACK) { if ((newzl = activeDefragAlloc(ob->ptr))) defragged++, ob->ptr = newzl; } else if (ob->encoding == OBJ_ENCODING_HT) { -- cgit v1.2.1