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
This commit is contained in:
parent
2475d95374
commit
bc90ce7788
|
@ -1029,7 +1029,7 @@ public void writePack(ProgressMonitor compressMonitor,
|
||||||
stats.totalObjects = objCnt;
|
stats.totalObjects = objCnt;
|
||||||
beginPhase(PackingPhase.WRITING, writeMonitor, objCnt);
|
beginPhase(PackingPhase.WRITING, writeMonitor, objCnt);
|
||||||
long writeStart = System.currentTimeMillis();
|
long writeStart = System.currentTimeMillis();
|
||||||
|
try {
|
||||||
out.writeFileHeader(PACK_VERSION_GENERATED, objCnt);
|
out.writeFileHeader(PACK_VERSION_GENERATED, objCnt);
|
||||||
out.flush();
|
out.flush();
|
||||||
|
|
||||||
|
@ -1042,6 +1042,7 @@ public void writePack(ProgressMonitor compressMonitor,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stats.reusedPacks = Collections.unmodifiableList(cachedPacks);
|
||||||
for (CachedPack pack : cachedPacks) {
|
for (CachedPack pack : cachedPacks) {
|
||||||
long deltaCnt = pack.getDeltaCount();
|
long deltaCnt = pack.getDeltaCount();
|
||||||
stats.reusedObjects += pack.getObjectCount();
|
stats.reusedObjects += pack.getObjectCount();
|
||||||
|
@ -1051,21 +1052,21 @@ public void writePack(ProgressMonitor compressMonitor,
|
||||||
}
|
}
|
||||||
writeChecksum(out);
|
writeChecksum(out);
|
||||||
out.flush();
|
out.flush();
|
||||||
|
} finally {
|
||||||
stats.timeWriting = System.currentTimeMillis() - writeStart;
|
stats.timeWriting = System.currentTimeMillis() - writeStart;
|
||||||
stats.totalBytes = out.length();
|
|
||||||
stats.reusedPacks = Collections.unmodifiableList(cachedPacks);
|
|
||||||
stats.depth = depth;
|
stats.depth = depth;
|
||||||
|
|
||||||
for (Statistics.ObjectType typeStat : stats.objectTypes) {
|
for (Statistics.ObjectType typeStat : stats.objectTypes) {
|
||||||
if (typeStat == null)
|
if (typeStat == null)
|
||||||
continue;
|
continue;
|
||||||
typeStat.cntDeltas += typeStat.reusedDeltas;
|
typeStat.cntDeltas += typeStat.reusedDeltas;
|
||||||
|
|
||||||
stats.reusedObjects += typeStat.reusedObjects;
|
stats.reusedObjects += typeStat.reusedObjects;
|
||||||
stats.reusedDeltas += typeStat.reusedDeltas;
|
stats.reusedDeltas += typeStat.reusedDeltas;
|
||||||
stats.totalDeltas += typeStat.cntDeltas;
|
stats.totalDeltas += typeStat.cntDeltas;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stats.totalBytes = out.length();
|
||||||
reader.release();
|
reader.release();
|
||||||
endPhase(writeMonitor);
|
endPhase(writeMonitor);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue