From 68cc21b60d83b5c4fb1de6c34a79836c51dd9b3b Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Wed, 27 Jul 2011 12:10:19 -0700 Subject: [PATCH] PackWriter: Skip progress messages on fast operations If the "Finding sources" phase will complete in <1 second with no delta compression enabled, don't bother showing the progress meter for this phase. Small repositories on the local filesystem tend to rip through this phase always subsecond and the ProgressMonitor display can actually slow the operation down. If delta compression is enabled, there are two phases that may run very quickly. Set the timer to 500 milliseconds instead, reducing the risk that the user has to wait longer than 1 second before any sort of output from the packer occurs. Change-Id: I58110f17e2a5ffa0134f9768b94804d16bbb8399 Signed-off-by: Shawn O. Pearce --- .../eclipse/jgit/storage/pack/PackWriter.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java index 8a912aeb6..3007b809c 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java @@ -80,6 +80,7 @@ import org.eclipse.jgit.errors.MissingObjectException; import org.eclipse.jgit.errors.StoredObjectRepresentationNotAvailableException; import org.eclipse.jgit.lib.AnyObjectId; import org.eclipse.jgit.lib.AsyncObjectSizeQueue; +import org.eclipse.jgit.lib.BatchingProgressMonitor; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.NullProgressMonitor; import org.eclipse.jgit.lib.ObjectId; @@ -640,10 +641,21 @@ public class PackWriter { if (writeMonitor == null) writeMonitor = NullProgressMonitor.INSTANCE; - if (reuseSupport != null && ( + boolean needSearchForReuse = reuseSupport != null && ( reuseDeltas || config.isReuseObjects() - || !cachedPacks.isEmpty())) + || !cachedPacks.isEmpty()); + + if (compressMonitor instanceof BatchingProgressMonitor) { + long delay = 1000; + if (needSearchForReuse && config.isDeltaCompress()) + delay = 500; + ((BatchingProgressMonitor) compressMonitor).setDelayStart( + delay, + TimeUnit.MILLISECONDS); + } + + if (needSearchForReuse) searchForReuse(compressMonitor); if (config.isDeltaCompress()) searchForDeltas(compressMonitor);