summaryrefslogtreecommitdiff
path: root/templates/hooks--pre-receive.sample
diff options
context:
space:
mode:
authorLibravatar Patrick Steinhardt <ps@pks.im>2021-09-01 15:09:45 +0200
committerLibravatar Junio C Hamano <gitster@pobox.com>2021-09-01 12:43:56 -0700
commit47c61004c7cfbb8662b13fac813b45e3fd214665 (patch)
tree414dc8e4d8f717eb365a81d6a54e00a2b5a1a008 /templates/hooks--pre-receive.sample
parentfetch: speed up lookup of want refs via commit-graph (diff)
downloadtgif-47c61004c7cfbb8662b13fac813b45e3fd214665.tar.xz
fetch: avoid unpacking headers in object existence check
When updating local refs after the fetch has transferred all objects, we do an object existence test as a safety guard to avoid updating a ref to an object which we don't have. We do so via `oid_object_info()`: if it returns an error, then we know the object does not exist. One side effect of `oid_object_info()` is that it parses the object's type, and to do so it must unpack the object header. This is completely pointless: we don't care for the type, but only want to assert that the object exists. Refactor the code to use `repo_has_object_file()`, which both makes the code's intent clearer and is also faster because it does not unpack object headers. In a real-world repo with 2.3M refs, this results in a small speedup when doing a mirror-fetch: Benchmark #1: HEAD~: git-fetch Time (mean ± σ): 33.686 s ± 0.176 s [User: 30.119 s, System: 5.262 s] Range (min … max): 33.512 s … 33.944 s 5 runs Benchmark #2: HEAD: git-fetch Time (mean ± σ): 31.247 s ± 0.195 s [User: 28.135 s, System: 5.066 s] Range (min … max): 30.948 s … 31.472 s 5 runs Summary 'HEAD: git-fetch' ran 1.08 ± 0.01 times faster than 'HEAD~: git-fetch' Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'templates/hooks--pre-receive.sample')
0 files changed, 0 insertions, 0 deletions