Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Halstrick2012-06-28 18:06:29 +0000
committerKevin Sawicki2012-06-28 18:06:29 +0000
commitc9e507c0b9fe9a91ae65dfa8a3bcaa1f739a5686 (patch)
treeefe78249a3d2d2c3e1de265d5f331f4582cca147
parent2f27d5ae12ef0dbb8c493573e389bf9f6a10f570 (diff)
downloadjgit-c9e507c0b9fe9a91ae65dfa8a3bcaa1f739a5686.tar.gz
jgit-c9e507c0b9fe9a91ae65dfa8a3bcaa1f739a5686.tar.xz
jgit-c9e507c0b9fe9a91ae65dfa8a3bcaa1f739a5686.zip
Improve performance of persisting an index by magnitudesstable-2.0
When updating smudged entries use a pathfilter to iterate only over working tree files which have an associated smudged index entry. Commit dac66672df0535f61a13273524d46e1e0012ca69 introduced that we check and update smudged entries while persisting a dircache. Before that commit adding a file to git caused file i/o for the index file, the object database (to store new content) and all files we wanted to add (to read new content). After that commit we have additionally file i/o for every file in the working tree (even ignored files). Especially on windows iterating over the working tree can be very time consuming. This decreased the performance of persisting a dircache dramatically (I measured factors 4 to 10 while adding a file to linux kernel repo). One could easily see this effect when dragging&dropping modified files in a linux kernel repo in the egit staging view. Change-Id: I568dec77635013cf6bb46f652d3f2b89de041c82 Signed-off-by: Kevin Sawicki <kevin@github.com>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java11
1 files changed, 11 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java
index 9108d9235d..f24c9b2a5b 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java
@@ -57,8 +57,10 @@ import java.io.UnsupportedEncodingException;
import java.security.DigestOutputStream;
import java.security.MessageDigest;
import java.text.MessageFormat;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
+import java.util.List;
import org.eclipse.jgit.errors.CorruptObjectException;
import org.eclipse.jgit.errors.LockFailedException;
@@ -74,6 +76,7 @@ import org.eclipse.jgit.storage.file.FileSnapshot;
import org.eclipse.jgit.storage.file.LockFile;
import org.eclipse.jgit.treewalk.FileTreeIterator;
import org.eclipse.jgit.treewalk.TreeWalk;
+import org.eclipse.jgit.treewalk.filter.PathFilterGroup;
import org.eclipse.jgit.util.FS;
import org.eclipse.jgit.util.IO;
import org.eclipse.jgit.util.MutableInteger;
@@ -941,7 +944,15 @@ public class DirCache {
*/
private void updateSmudgedEntries() throws IOException {
TreeWalk walk = new TreeWalk(repository);
+ List<String> paths = new ArrayList<String>(128);
try {
+ for (int i = 0; i < entryCnt; i++)
+ if (sortedEntries[i].isSmudged())
+ paths.add(sortedEntries[i].getPathString());
+ if (paths.isEmpty())
+ return;
+ walk.setFilter(PathFilterGroup.createFromStrings(paths));
+
DirCacheIterator iIter = new DirCacheIterator(this);
FileTreeIterator fIter = new FileTreeIterator(repository);
walk.addTree(iIter);

Back to the top