• Filipe Oliveira (Redis)'s avatar
    Optimize SSCAN command in case of listpack or intset encoding: avoid the usage... · f2f85ba3
    Filipe Oliveira (Redis) authored
    Optimize SSCAN command in case of listpack or intset encoding: avoid the usage of intermediate list. From 2N to N iterations (#13530)
    
    On SSCAN, in case of listpack and intset encoding we actually reply the
    entire set, and always reply with the cursor 0.
    
    For those cases, we don't need to accumulate the replies in a list and
    can completely avoid the overhead of list appending and then iterating
    over the list again -- meaning we do N iterations instead of 2N
    iterations over the SET and save intermediate memory as well.
    
    Preliminary benchmarks, `SSCAN set:100 0`, showcased an improvement of
    60% as visible bellow on a SET with 100 string elements (listpack
    encoded).
    f2f85ba3
db.c 104 KB