summaryrefslogtreecommitdiff
path: root/pack-objects.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2018-04-14 15:35:10 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-04-16 03:38:59 (GMT)
commitac77d0c370dc5b23ac1ec4a13c754fe7ffa48564 (patch)
tree44d01cc4c9a8da445b8c0b2a7d9a8ed5adbc16c4 /pack-objects.c
parent27a7d0679f17bd536f566e76e51058de0e1fa17a (diff)
downloadgit-ac77d0c370dc5b23ac1ec4a13c754fe7ffa48564.zip
git-ac77d0c370dc5b23ac1ec4a13c754fe7ffa48564.tar.gz
git-ac77d0c370dc5b23ac1ec4a13c754fe7ffa48564.tar.bz2
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>
Diffstat (limited to 'pack-objects.c')
-rw-r--r--pack-objects.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/pack-objects.c b/pack-objects.c
index 08cfe68..e0c4600 100644
--- a/pack-objects.c
+++ b/pack-objects.c
@@ -143,6 +143,9 @@ void prepare_packing_data(struct packing_data *pdata)
} else {
prepare_in_pack_by_idx(pdata);
}
+
+ pdata->oe_size_limit = git_env_ulong("GIT_TEST_OE_SIZE",
+ 1U << OE_SIZE_BITS);
}
struct object_entry *packlist_alloc(struct packing_data *pdata,