]> source.dussan.org Git - jgit.git/commit
Fix RefUpdate performance for existing Refs 92/10792/1
authorRoberto Tyley <roberto.tyley@gmail.com>
Fri, 1 Mar 2013 21:49:58 +0000 (21:49 +0000)
committerRoberto Tyley <roberto.tyley@gmail.com>
Fri, 1 Mar 2013 21:49:58 +0000 (21:49 +0000)
commitf1dea3e279f4e8ca118e486cecdf7ab967279df3
tree9b01861bb0eb74b459c02c06c16b9372205b262f
parent178d55c24d784bc07adbb0d78de8ba1919843e86
Fix RefUpdate performance for existing Refs

No longer invoke the expensive RefDatabase.isNameConflicting() check on
updating existing refs, reducing batch ref update time by ~97%.

The RefDirectory implementation of isNameConflicting() is quite
slow (it has to do an expensive loose-ref scan) but it's only necessary
to perform this check on ref update if the ref is being *created* - if
the ref already exists, we can already guarantee that it does not
conflict with any other refs.

C-Git seems to use a similar condition before making the
is_refname_available() check:

https://github.com/git/git/blob/v1.8.1.4/refs.c#L1660-L1670

As an example of the effects on performance, here's a simple timing
experiment using The BFG to remove one file from the JGit repo:

---
$ wget http://repo1.maven.org/maven2/com/madgag/bfg-repo-cleaner/1.0.1/bfg-1.0.1.jar
$ git clone --mirror https://git.eclipse.org/r/p/jgit/jgit.git
$ java -jar bfg-1.0.1.jar -D make_jgit.sh jgit.git
....
Updating references:    100% (5760/5760)
...Ref update completed in 148,949 ms.

BFG run is complete!
---

The execution time for the run is completely dominated by the batch ref
update at the end. Repeating the experiment with BFG v1.0.2 (using JGit
patched with this change), the refs update is dramatically reduced:

---
Updating references:    100% (5760/5760)
...Ref update completed in 4,327 ms.
---

Change-Id: I9057bc4ee22f9cc269b1cc00c493841c71527cd6
org.eclipse.jgit/src/org/eclipse/jgit/lib/RefUpdate.java