summaryrefslogtreecommitdiff
path: root/src/server.h
diff options
context:
space:
mode:
authorViktor Söderqvist <viktor@zuiderkwast.se>2022-12-06 10:25:51 +0100
committerGitHub <noreply@github.com>2022-12-06 11:25:51 +0200
commit8a315fc285fc54c678b97107a02ee1627f2c1ebf (patch)
tree071fb308821df6f94a91e562a355b08db6e4774d /src/server.h
parent8f13ac10b46de0c6f3cb9fd5c9e86824aa1e8355 (diff)
downloadredis-8a315fc285fc54c678b97107a02ee1627f2c1ebf.tar.gz
When converting a set to dict, presize for one more element to be added (#11559)
In most cases when a listpack or intset is converted to a dict, the conversion is trigged when adding an element. The extra element is added after conversion to dict (in all cases except when the conversion is triggered by set-max-intset-entries being reached). If set-max-listpack-entries is set to a power of two, let's say 128, when adding the 129th element, the 128 element listpack is first converted to a dict with a hashtable presized for 128 elements. After converting to dict, the 129th element is added to the dict which immediately triggers incremental rehashing to size 256. This commit instead presizes the dict to one more element, with the assumption that conversion to dict is followed by adding another element, so the dict doesn't immediately need rehashing. Co-authored-by: sundb <sundbcn@gmail.com> Co-authored-by: Oran Agra <oran@redislabs.com>
Diffstat (limited to 'src/server.h')
-rw-r--r--src/server.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/server.h b/src/server.h
index 105b2db4e..1ce5ff781 100644
--- a/src/server.h
+++ b/src/server.h
@@ -3022,6 +3022,7 @@ int setTypeRandomElement(robj *setobj, char **str, size_t *len, int64_t *llele);
unsigned long setTypeRandomElements(robj *set, unsigned long count, robj *aux_set);
unsigned long setTypeSize(const robj *subject);
void setTypeConvert(robj *subject, int enc);
+int setTypeConvertAndExpand(robj *setobj, int enc, unsigned long cap, int panic);
robj *setTypeDup(robj *o);
/* Hash data type */