• Binbin's avatar
    Optimize HRANDFIELD and ZRANDMEMBER case 3 when listpack encoded (#12205) · 006ab26c
    Binbin authored
    Optimized HRANDFIELD and ZRANDMEMBER commands as in #8444,
    CASE 3 under listpack encoding. Boost optimization to CASE 2.5. 
    
    CASE 2.5 listpack only. Sampling unique elements, in non-random order.
    Listpack encoded hashes / zsets are meant to be relatively small, so
    HRANDFIELD_SUB_STRATEGY_MUL / ZRANDMEMBER_SUB_STRATEGY_MUL
    isn't necessary and we rather not make copies of the entries. Instead, we
    emit them directly to the output buffer.
    
    Simple benchmarks shows it provides some 400% improvement in HRANDFIELD
    and ZRANGESTORE both in CASE 3.
    
    Unrelated changes: remove useless setTypeRandomElements and fix a typo.
    006ab26c
t_zset.c 148 KB