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

@ -332,11 +332,11 @@ TEST_F(RdbTest, SaveManyDbs) {
TEST_F(RdbTest, HMapBugs) {
// Force kEncodingStrMap2 encoding.
server.hash_max_listpack_value = 0;
server.max_map_field_len = 0;
Run({"hset", "hmap1", "key1", "val", "key2", "val2"});
Run({"hset", "hmap2", "key1", string(690557, 'a')});
server.hash_max_listpack_value = 32;
server.max_map_field_len = 32;
Run({"debug", "reload"});
EXPECT_EQ(2, CheckedInt({"hlen", "hmap1"}));
}
@ -353,10 +353,10 @@ TEST_F(RdbTest, Issue1305) {
*/
// Force kEncodingStrMap2 encoding.
server.hash_max_listpack_value = 0;
server.max_map_field_len = 0;
Run({"hset", "hmap", "key1", "val", "key2", ""});
server.hash_max_listpack_value = 32;
server.max_map_field_len = 32;
Run({"debug", "reload"});
EXPECT_EQ(2, CheckedInt({"hlen", "hmap"}));
}