• debing.sun's avatar
    Add defragment support for HFE (#13229) · 80be2cc2
    debing.sun authored
    
    
    ## Background
    1. All hash objects that contain HFE are referenced by db->hexpires.
    2. All fields in a dict hash object with HFE are referenced by an
    ebucket.
    
    So when we defrag the hash object or the field in a dict with HFE, we
    also need to update the references in them.
    
    ## Interface
    1. Add a new interface `ebDefragItem`, which can accept a defrag
    callback to defrag items in ebuckets, and simultaneously update their
    references in the ebucket.
    
    ## Mainly changes
    1. The key type of dict of hash object is no longer sds, so add new
    `activeDefragHfieldDict()` to defrag the dict instead of
    `activeDefragSdsDict()`.
    2. When we defrag the dict of hash object by using `dictScanDefrag()`,
    we always set the defrag callback `defragKey` of `dictDefragFunctions`
    to NULL, because we can't reallocate a field with out updating it's
    reference in ebuckets.
    Instead, we will defrag the field of the dict and update its reference
    in the callback `dictScanDefrag` of dictScanFunction().
    3. When we defrag the hash robj with HFE, we will use `ebDefragItem` to
    defrag the robj and update the reference in db->hexpires.
    
    ## TODO:
    Defrag ebucket structure incremently, which will be handler in a future
    PR.
    
    ---------
    Co-authored-by: default avatarOzan Tezcan <ozantezcan@gmail.com>
    Co-authored-by: default avatarMoti Cohen <moti.cohen@redis.com>
    80be2cc2
memefficiency.tcl 34.9 KB