diff options
author | Ivan Frade <ifrade@google.com> | 2023-11-07 11:36:51 -0800 |
---|---|---|
committer | Ivan Frade <ifrade@google.com> | 2023-11-07 13:41:54 -0800 |
commit | c46b54eeac1cb2aaf62d4394fb7f60c848eab7b1 (patch) | |
tree | a603b5fd1a4813d7707f86e2c2a97cbf37e5f748 /org.eclipse.jgit/src/org | |
parent | 3937300f3eb4dd557ec2d195f21793f737d6cb4e (diff) | |
download | jgit-c46b54eeac1cb2aaf62d4394fb7f60c848eab7b1.tar.gz jgit-c46b54eeac1cb2aaf62d4394fb7f60c848eab7b1.zip |
CommitGraphWriter: Unnest generation-number progress
The ProgressMonitor task to track the calculation of generation
numbers is nested inside the task that follows the writing of all
lines in the commit-graph. ProgressMonitor doesn't support nested
tasks and this confuses the counting.
Move the start/end of the "writing commit graph" task to the
writeCommitData section, after calculating the generation
numbers. Make that task track by commits instead of by lines.
Moving the start/end of the progress task to the chunk-writing
functions is clearer and easier to extend.
Logging of GC before:
Writing out commit-graph in 3 passes: 51% ( 9807/19358)
Computing commit-graph generation numbers: 100% (9551/9551)
Logging of GC after:
Computing commit-graph generation numbers: 100% (9551/9551)
Writing out commit-graph: 100% (9551/9551)
Change-Id: I87d69c06c9a3c7e75be12b6f0d1a63b5924e298a
Diffstat (limited to 'org.eclipse.jgit/src/org')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/commitgraph/CommitGraphWriter.java | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/commitgraph/CommitGraphWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/commitgraph/CommitGraphWriter.java index f72c1eaa8c..1c5f5b8521 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/commitgraph/CommitGraphWriter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/commitgraph/CommitGraphWriter.java @@ -31,7 +31,6 @@ import java.io.IOException; import java.io.InterruptedIOException; import java.io.OutputStream; import java.nio.ByteBuffer; -import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; @@ -131,13 +130,6 @@ public class CommitGraphWriter { chunks = Collections.unmodifiableList(chunks); long expectedSize = calculateExpectedSize(chunks); - long writeCount = 256L + 2 * graphCommits.size() - + graphCommits.getExtraEdgeCnt(); - monitor.beginTask( - MessageFormat.format(JGitText.get().writingOutCommitGraph, - Integer.valueOf(chunks.size())), - (int) writeCount); - try (CancellableDigestOutputStream out = new CancellableDigestOutputStream( monitor, commitGraphStream)) { writeHeader(out, chunks.size()); @@ -153,8 +145,6 @@ public class CommitGraphWriter { } catch (InterruptedIOException e) { throw new IOException(JGitText.get().commitGraphWritingCancelled, e); - } finally { - monitor.endTask(); } return Stats.from(bloomFilterChunks); } @@ -290,6 +280,8 @@ public class CommitGraphWriter { private void writeCommitData(ProgressMonitor monitor, CancellableDigestOutputStream out) throws IOException { int[] generations = computeGenerationNumbers(monitor); + monitor.beginTask(JGitText.get().writingOutCommitGraph, + graphCommits.size()); int num = 0; byte[] tmp = new byte[hashsz + COMMIT_DATA_WIDTH]; int i = 0; @@ -330,6 +322,7 @@ public class CommitGraphWriter { out.getWriteMonitor().update(1); i++; } + monitor.endTask(); } private int[] computeGenerationNumbers(ProgressMonitor monitor) |