Skip to content
  • Duy Nguyen's avatar
    pack-objects: shrink size field in struct object_entry · ac77d0c3
    Duy Nguyen authored and Junio C Hamano's avatar Junio C Hamano committed
    
    
    It's very very rare that an uncompressed object is larger than 4GB
    (partly because Git does not handle those large files very well to
    begin with). Let's optimize it for the common case where object size
    is smaller than this limit.
    
    Shrink size field down to 31 bits and one overflow bit. If the size is
    too large, we read it back from disk. As noted in the previous patch,
    we need to return the delta size instead of canonical size when the
    to-be-reused object entry type is a delta instead of a canonical one.
    
    Add two compare helpers that can take advantage of the overflow
    bit (e.g. if the file is 4GB+, chances are it's already larger than
    core.bigFileThreshold and there's no point in comparing the actual
    value).
    
    Another note about oe_get_size_slow(). This function MUST be thread
    safe because SIZE() macro is used inside try_delta() which may run in
    parallel. Outside parallel code, no-contention locking should be dirt
    cheap (or insignificant compared to i/o access anyway). To exercise
    this code, it's best to run the test suite with something like
    
        make test GIT_TEST_OE_SIZE=4
    
    which forces this code on all objects larger than 3 bytes.
    
    Signed-off-by: default avatarNguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    ac77d0c3