• filipe oliveira's avatar
    Reintroduce lua argument cache in luaRedisGenericCommand removed in v7.0 (#11541) · 2d80cd78
    filipe oliveira authored
    This mechanism aims to reduce calls to malloc and free when
    preparing the arguments the script sends to redis commands.
    This is a mechanism was originally implemented in 48c49c48
    and 4f686555
    
    , and was removed in #10220 (thinking it's not needed
    and that it has no impact), but it now turns out it was wrong, and it
    indeed provides some 5% performance improvement.
    
    The implementation is a little bit too simplistic, it assumes consecutive
    calls use the same size in the same arg index, but that's arguably
    sufficient since it's only aimed at caching very small things.
    
    We could even consider always pre-allocating args to the full
    LUA_CMD_OBJCACHE_MAX_LEN (64 bytes) rather than the right size for the argument,
    that would increase the chance they'll be able to be re-used.
    But in some way this is already happening since we're using
    sdsalloc, which in turn uses s_malloc_usable and takes ownership
    of the full side of the allocation, so we are padded to the allocator
    bucket size.
    Co-authored-by: default avatarOran Agra <oran@redislabs.com>
    Co-authored-by: default avatarsundb <sundbcn@gmail.com>
    2d80cd78
scripting.tcl 69 KB