• sundb's avatar
    Add listpack encoding for list (#11303) · 2168ccc6
    sundb authored
    Improve memory efficiency of list keys
    
    ## Description of the feature
    The new listpack encoding uses the old `list-max-listpack-size` config
    to perform the conversion, which we can think it of as a node inside a
    quicklist, but without 80 bytes overhead (internal fragmentation included)
    of quicklist and quicklistNode structs.
    For example, a list key with 5 items of 10 chars each, now takes 128 bytes
    instead of 208 it used to take.
    
    ## Conversion rules
    * Convert listpack to quicklist
      When the listpack length or size reaches the `list-max-listpack-size` limit,
      it will be converted to a quicklist.
    * Convert quicklist to listpack
      When a quicklist has only one node, and its length or size is reduced to half
      of the `list-max-listpack-size` limit, it will be converted to a listpack.
      This is done to avoid frequent conversions when we add or remove at the bounding size or length.
        
    ## Interface changes
    1. add list entry param to listTypeSetIte...
    2168ccc6
defrag.c 45.4 KB