]> git.ipfire.org Git - thirdparty/git.git/commit - pack-objects.h
pack-objects: shrink size field in struct object_entry
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Sat, 14 Apr 2018 15:35:10 +0000 (17:35 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 16 Apr 2018 03:38:59 +0000 (12:38 +0900)
commitac77d0c370dc5b23ac1ec4a13c754fe7ffa48564
tree44d01cc4c9a8da445b8c0b2a7d9a8ed5adbc16c4
parent27a7d0679f17bd536f566e76e51058de0e1fa17a
pack-objects: shrink size field in struct object_entry

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: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/pack-objects.c
pack-objects.c
pack-objects.h
t/README