• Binbin's avatar
    Performance improvement to ZADD and ZRANGESTORE, convert to skiplist and... · 48757934
    Binbin authored
    Performance improvement to ZADD and ZRANGESTORE, convert to skiplist and expand dict in advance (#12185)
    
    For zsets that will eventually be stored as the skiplist encoding (has a dict),
    we can convert it to skiplist ahead of time. This change checks the number
    of arguments in the ZADD command, and converts the data-structure
    if the number of new entries exceeds the listpack-max-entries configuration.
    This can cause us to over-allocate memory if there are duplicate entries in the
    input, which is unexpected.
    
    For ZRANGESTORE, we know the size of the zset, so we can expand
    the dict in advance, to avoid the temporary dict from being rehashed
    while it grows.
    
    Simple benchmarks shows it provides some 4% improvement in ZADD and 20% in ZRANGESTORE
    48757934
t_zset.c 148 KB