summaryrefslogtreecommitdiff
path: root/src/listpack.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/listpack.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/listpack.h')
-rw-r--r--src/listpack.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/listpack.h b/src/listpack.h
index 304ccd32c..a60f089f9 100644
--- a/src/listpack.h
+++ b/src/listpack.h
@@ -82,6 +82,7 @@ unsigned char *lpLast(unsigned char *lp);
unsigned char *lpNext(unsigned char *lp, unsigned char *p);
unsigned char *lpPrev(unsigned char *lp, unsigned char *p);
size_t lpBytes(unsigned char *lp);
+size_t lpEstimateBytesRepeatedInteger(long long lval, unsigned long rep);
unsigned char *lpSeek(unsigned char *lp, long index);
typedef int (*listpackValidateEntryCB)(unsigned char *p, unsigned int head_count, void *userdata);
int lpValidateIntegrity(unsigned char *lp, size_t size, int deep,