Track object inflation time in DfsReaderIoStats

This can help track down poor long tail performance that isn't accounted
for in the readIdxMicros or readBlockMicros metrics.

Change-Id: I701b9cfcc124f4ddb860d1766a11ea3557e604ce
Signed-off-by: Terry Parker <tparker@google.com>
This commit is contained in:
Terry Parker 2019-03-06 10:01:16 -08:00
parent 16f75aa9da
commit e48410ae9a
2 changed files with 14 additions and 0 deletions

View File

@ -757,6 +757,7 @@ int copy(BlockBasedFile file, long position, byte[] dstbuf, int dstoff,
*/ */
int inflate(DfsPackFile pack, long position, byte[] dstbuf, int inflate(DfsPackFile pack, long position, byte[] dstbuf,
boolean headerOnly) throws IOException, DataFormatException { boolean headerOnly) throws IOException, DataFormatException {
long start = System.nanoTime();
prepareInflater(); prepareInflater();
pin(pack, position); pin(pack, position);
position += block.setInput(position, inf); position += block.setInput(position, inf);
@ -765,6 +766,7 @@ int inflate(DfsPackFile pack, long position, byte[] dstbuf,
dstoff += n; dstoff += n;
if (inf.finished() || (headerOnly && dstoff == dstbuf.length)) { if (inf.finished() || (headerOnly && dstoff == dstbuf.length)) {
stats.inflatedBytes += dstoff; stats.inflatedBytes += dstoff;
stats.inflationMicros += BlockBasedFile.elapsedMicros(start);
return dstoff; return dstoff;
} else if (inf.needsInput()) { } else if (inf.needsInput()) {
pin(pack, position); pin(pack, position);

View File

@ -85,6 +85,9 @@ public static class Accumulator {
/** Total number of bytes decompressed. */ /** Total number of bytes decompressed. */
long inflatedBytes; long inflatedBytes;
/** Total microseconds spent inflating compressed bytes. */
long inflationMicros;
Accumulator() { Accumulator() {
} }
} }
@ -186,4 +189,13 @@ public long getReadBlocksMicros() {
public long getInflatedBytes() { public long getInflatedBytes() {
return stats.inflatedBytes; return stats.inflatedBytes;
} }
/**
* Get total microseconds spent inflating compressed bytes.
*
* @return total microseconds inflating compressed bytes.
*/
public long getInflationMicros() {
return stats.inflationMicros;
}
} }