]> source.dussan.org Git - jgit.git/commit
BasePackFetchConnection: Skip object/ref lookups if local repo is empty 02/1173802/3
authorDariusz Luksza <dariusz.luksza@gmail.com>
Mon, 18 Dec 2023 18:24:49 +0000 (18:24 +0000)
committerDariusz Luksza <dariusz.luksza@gmail.com>
Wed, 20 Dec 2023 08:31:14 +0000 (08:31 +0000)
commit7884873160727069944afc4e2b36046aa2cff550
tree2b1ae49af089489415b1bd1549b318844b819374
parentfaa50c683d2496d486aac5efac6c89f9652e13ff
BasePackFetchConnection: Skip object/ref lookups if local repo is empty

When cloning repository some of the operations in
`BasePackFetchConnection` can be skipped. We don't need to advertise
packs, compute "wanted time" or wanted refs to send. All of those
operations will try to read objects from an empty repository which
always results in a missing object.

This saves 99.9% of `LooseObjects.open()` calls which dramatically
speeds up object negotiation in V2 protocol.

In testing on JGit (v6.8.0.202311291450-r) repository, which contains
564 refs, the number of calls to `LooseObjects.open()` was reduced from
1187 to 1.

Skipping a call to `markRefsAdvertised()` initially reduced be above
number to 623. Then assuming "0" "want time" an on empty repository
pushed the calls down to 312. Finally, skipping objects reachability on
empty repository set calls down to 1.

The last call is performed from `FetchProcess.asForIsComplete()` which
probably needs to stay in place.

Bug: jgit-5
Change-Id: I2480690726ea54d3b1593380bc8f8d15b4d6afc6
org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackFetchConnection.java