Encode small hashes with a ziplist#285
Conversation
To improve the performance of the ziplist implementation, some functions have been converted to macros to avoid unnecessary stack movement and duplicate variable assignments.
|
The following graph illustrates the performance impact of the ziplist backed hashes. All commands are executed against a hash that already contains N field/value pairs (23 + 5 bytes), and use randomized field names with a field space of N. The only command that doesn't show improvement is |
|
The memory impact for small fields/values is 9+N bytes with N being the number of pairs in the hash. The constant number is caused by the extra bytes to store length, size in bytes and a pointer to the tail element. The variable number is caused by a backlink for the value entry, which is not present in the zipmap encoding. |
|
Thank you Pieter! Great work. I'll merge and add the missing integration test in the next days. This was an important part of the 2.6 release... very cool to have it now that we I'm going to call the feature freeze. |
|
p.s did you generated the graphs with |
|
I'll push to this pull request when I get around to the integration test. The graph uses the |
|
@antirez The integration test revealed an error in the conversion code, so it's a good thing the merge was postponed. This patch touches a little bit of ziplist, not very invasively, but could therefore use a little more testing IMO. |
fix comments forgotten in #285 (zipmap -> ziplist)
Fix NPE in BuilderFactory for Double.
Remove some dead code in object.c, ziplist is no longer used in 7.0 Some backgrounds: zipmap - hash: replaced by ziplist in redis#285 ziplist - hash: replaced by listpack in redis#8887 ziplist - zset: replaced by listpack in redis#9366 ziplist - list: replaced by quicklist (listpack) in redis#2143 / redis#9740
Remove some dead code in object.c, ziplist is no longer used in 7.0 Some backgrounds: zipmap - hash: replaced by ziplist in #285 ziplist - hash: replaced by listpack in #8887 ziplist - zset: replaced by listpack in #9366 ziplist - list: replaced by quicklist (listpack) in #2143 / #9740 Moved the location of ziplist.h in the server.c
[7.0.2] add tarball tests
Remove some dead code in object.c, ziplist is no longer used in 7.0 Some backgrounds: zipmap - hash: replaced by ziplist in redis#285 ziplist - hash: replaced by listpack in redis#8887 ziplist - zset: replaced by listpack in redis#9366 ziplist - list: replaced by quicklist (listpack) in redis#2143 / redis#9740 Moved the location of ziplist.h in the server.c
Unified VSX and S390X code path, remove vpermxor

This patch switches the encoding of small hashes from zipmap to ziplist (continuation of issue #188). This is a first stab, and it may need more work: tests pass, but I haven't done performance testing (throughput, memory). Because the vanilla ziplist API is used, which doesn't provide a function to replace an element, HSET is implemented as a delete followed by a push. This causes the fields in the ziplist encoded hash to be ordered by modification time (I see this more as a by-effect than a feature).
I haven't tested the loading of a zipmap encoded hash from an older RDB yet. We may want to add an integration test for that (i.e. one that includes a prefabricated RDB with such a key).