diff options
author | Shawn Pearce <sop@google.com> | 2014-09-04 12:41:24 -0700 |
---|---|---|
committer | Shawn Pearce <sop@google.com> | 2014-09-04 12:45:18 -0700 |
commit | bc90ce7788e77af11552799cecf65edeb97e3b7c (patch) | |
tree | b19ae3a0bc4483f07d9065bd9998fa01a423a85c | |
parent | 2475d95374d28c7df4ac12baef22090da4f409ba (diff) | |
download | jgit-bc90ce7788e77af11552799cecf65edeb97e3b7c.tar.gz jgit-bc90ce7788e77af11552799cecf65edeb97e3b7c.zip |
PackWriter: Report more stats during partial writes
It can be useful for a server operator to know how long a pack
writer spent writing out objects, even if the request aborts and
never finishes.
Record more of the stats data inside of a finally block, to
ensure these can be included into the server's monitoring.
Change-Id: I00858aa393a948f8e742e64ae4c00953eadaef95
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java | 57 |
1 files changed, 29 insertions, 28 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java index f3791e66fa..79dc11ead1 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java @@ -1029,43 +1029,44 @@ public class PackWriter { stats.totalObjects = objCnt; beginPhase(PackingPhase.WRITING, writeMonitor, objCnt); long writeStart = System.currentTimeMillis(); + try { + out.writeFileHeader(PACK_VERSION_GENERATED, objCnt); + out.flush(); - out.writeFileHeader(PACK_VERSION_GENERATED, objCnt); - out.flush(); + writeObjects(out); + if (!edgeObjects.isEmpty() || !cachedPacks.isEmpty()) { + for (Statistics.ObjectType typeStat : stats.objectTypes) { + if (typeStat == null) + continue; + stats.thinPackBytes += typeStat.bytes; + } + } + + stats.reusedPacks = Collections.unmodifiableList(cachedPacks); + for (CachedPack pack : cachedPacks) { + long deltaCnt = pack.getDeltaCount(); + stats.reusedObjects += pack.getObjectCount(); + stats.reusedDeltas += deltaCnt; + stats.totalDeltas += deltaCnt; + reuseSupport.copyPackAsIs(out, pack, reuseValidate); + } + writeChecksum(out); + out.flush(); + } finally { + stats.timeWriting = System.currentTimeMillis() - writeStart; + stats.depth = depth; - writeObjects(out); - if (!edgeObjects.isEmpty() || !cachedPacks.isEmpty()) { for (Statistics.ObjectType typeStat : stats.objectTypes) { if (typeStat == null) continue; - stats.thinPackBytes += typeStat.bytes; + typeStat.cntDeltas += typeStat.reusedDeltas; + stats.reusedObjects += typeStat.reusedObjects; + stats.reusedDeltas += typeStat.reusedDeltas; + stats.totalDeltas += typeStat.cntDeltas; } } - for (CachedPack pack : cachedPacks) { - long deltaCnt = pack.getDeltaCount(); - stats.reusedObjects += pack.getObjectCount(); - stats.reusedDeltas += deltaCnt; - stats.totalDeltas += deltaCnt; - reuseSupport.copyPackAsIs(out, pack, reuseValidate); - } - writeChecksum(out); - out.flush(); - stats.timeWriting = System.currentTimeMillis() - writeStart; stats.totalBytes = out.length(); - stats.reusedPacks = Collections.unmodifiableList(cachedPacks); - stats.depth = depth; - - for (Statistics.ObjectType typeStat : stats.objectTypes) { - if (typeStat == null) - continue; - typeStat.cntDeltas += typeStat.reusedDeltas; - - stats.reusedObjects += typeStat.reusedObjects; - stats.reusedDeltas += typeStat.reusedDeltas; - stats.totalDeltas += typeStat.cntDeltas; - } - reader.release(); endPhase(writeMonitor); } |