• Viktor Söderqvist's avatar
    When converting a set to dict, presize for one more element to be added (#11559) · 8a315fc2
    Viktor Söderqvist authored
    
    
    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: default avatarsundb <sundbcn@gmail.com>
    Co-authored-by: default avatarOran Agra <oran@redislabs.com>
    8a315fc2
rdb.c 139 KB