fix: improve performance of listpack sorted sets (#1885)

1. Cherry-pick changes from Redis 7 that encode integer scores more efficiently
2. Introduces optimization that first checks if the new element should be the last
   for listpack sorted sets.
3. Consolidates listpack related constants and tightens usage for listpack.
4. Introduce MEMORY USAGE command.
5. Introduce a small delay before decommitting memory pages back to OS.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
Roman Gershman 2023-09-19 19:52:34 +03:00 committed by GitHub
parent cfd83a66a2
commit 8d1474aeac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 124 additions and 279 deletions

View file

@ -469,8 +469,8 @@ int RobjWrapper::ZsetAdd(double score, sds ele, int in_flags, int* out_flags, do
/* check if the element is too large or the list
* becomes too long *before* executing zzlInsert. */
if (zl_len + 1 > server.zset_max_listpack_entries ||
sdslen(ele) > server.zset_max_listpack_value || !lpSafeToAdd(lp, sdslen(ele))) {
if (zl_len >= server.zset_max_listpack_entries ||
sdslen(ele) > server.zset_max_listpack_value) {
unique_ptr<SortedMap> ss = SortedMap::FromListPack(tl.local_mr, lp);
lpFree(lp);
inner_obj_ = ss.release();