• L
    hints for narrowing down FindFile range and avoiding checking unrelevant L0 files · 0f2d7681
    Lei Jin 提交于
    Summary:
    The file tree structure in Version is prebuilt and the range of each file is known.
    On the Get() code path, we do binary search in FindFile() by comparing
    target key with each file's largest key and also check the range for each L0 file.
    With some pre-calculated knowledge, each key comparision that has been done can serve
    as a hint to narrow down further searches:
    (1) If a key falls within a L0 file's range, we can safely skip the next
    file if its range does not overlap with the current one.
    (2) If a key falls within a file's range in level L0 - Ln-1, we should only
    need to binary search in the next level for files that overlap with the current one.
    
    (1) will be able to skip some files depending one the key distribution.
    (2) can greatly reduce the range of binary search, especially for bottom
    levels, given that one file most likely only overlaps with N files from
    the level below (where N is max_bytes_for_level_multiplier). So on level
    L, we will only look at ~N files instead of N^L files.
    
    Some inital results: measured with 500M key DB, when write is light (10k/s = 1.2M/s), this
    improves QPS ~7% on top of blocked bloom. When write is heavier (80k/s =
    9.6M/s), it gives us ~13% improvement.
    
    Test Plan: make all check
    
    Reviewers: haobo, igor, dhruba, sdong, yhchiang
    
    Reviewed By: haobo
    
    CC: leveldb
    
    Differential Revision: https://reviews.facebook.net/D17205
    0f2d7681
Makefile 20.4 KB