• A
    sdscatvprintf(): guess buflen using format length. · 7a20f096
    antirez 提交于
    sdscatvprintf() uses a loop where it tries to output the formatted
    string in a buffer of the initial length, if there was not enough room,
    a buffer of doubled size is tried and so forth.
    
    The initial guess for the buffer length was very poor, an hardcoded
    "16". This caused the printf to be processed multiple times without a
    good reason. Given that printf functions are already not fast, the
    overhead was significant.
    
    The new heuristic is to use a buffer 4 times the length of the format
    buffer, and 32 as minimal size. This appears to be a good balance for
    typical uses of the function inside the Redis code base.
    
    This change improved INFO command performances 3 times.
    7a20f096
sds.c 27.7 KB