]> source.dussan.org Git - jgit.git/commit
RefDirectory.scanRef: Re-use file existence check done in snapshot creation 90/188290/2
authorKaushik Lingarkar <quic_kaushikl@quicinc.com>
Mon, 29 Nov 2021 20:14:56 +0000 (12:14 -0800)
committerMatthias Sohn <matthias.sohn@sap.com>
Fri, 3 Dec 2021 21:06:46 +0000 (22:06 +0100)
commitf829f5f838e0f9c17373ea6cb3407976a8f395ff
tree5ecf9c29ecda7b3ae0aabc10b7fe1c34af785665
parent5606a53151e8b9b4785e5c01513eb331998b8278
RefDirectory.scanRef: Re-use file existence check done in snapshot creation

Return immediately in scanRef if the loose ref was identified as
missing when a snapshot was attempted for the ref. This will help
performance of scanRef when the ref is packed but has a corresponding
empty dir in 'refs/'.

For example, consider the case where we create 50k sharded refs in
a new namespace called 'new-refs' using an atomic 'BatchRefUpdate'.
The refs are named like 'refs/new-refs/01/1/1', 'refs/new-refs/01/1/2',
'refs/new-refs/01/1/3' and so on. After the refs are created, the
'new-refs' namespace looks like below:

$ find refs/new-refs -type f | wc -l
0

$ find refs/new-refs -type d | wc -l
5101

At this point, an 'exactRef' call on each of the 50k refs without
this change takes ~2.5s, where as with this change it takes ~1.5s.

Change-Id: I926bc41b9ae89a1a792b1b5ec9a17b05271c906b
Signed-off-by: Kaushik Lingarkar <quic_kaushikl@quicinc.com>
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileSnapshot.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java