|
@@ -35,6 +35,7 @@ import org.apache.hadoop.io.compress.CompressionCodec;
|
|
|
import org.apache.hadoop.io.compress.CompressionCodecFactory;
|
|
|
import org.apache.hadoop.util.LineReader;
|
|
|
import org.junit.After;
|
|
|
+import org.junit.Assert;
|
|
|
import org.junit.Assume;
|
|
|
import org.junit.Before;
|
|
|
import org.junit.Test;
|
|
@@ -216,12 +217,18 @@ public class ITestS3AInputStreamPerformance extends S3AScaleTestBase {
|
|
|
long count = 0;
|
|
|
// implicitly rounding down here
|
|
|
long blockCount = len / blockSize;
|
|
|
+ long totalToRead = blockCount * blockSize;
|
|
|
+ long minimumBandwidth = 128 * 1024;
|
|
|
+ int maxResetCount = 4;
|
|
|
+ int resetCount = 0;
|
|
|
for (long i = 0; i < blockCount; i++) {
|
|
|
int offset = 0;
|
|
|
int remaining = blockSize;
|
|
|
+ long blockId = i + 1;
|
|
|
NanoTimer blockTimer = new NanoTimer();
|
|
|
int reads = 0;
|
|
|
while (remaining > 0) {
|
|
|
+ NanoTimer readTimer = new NanoTimer();
|
|
|
int bytesRead = in.read(block, offset, remaining);
|
|
|
reads++;
|
|
|
if (bytesRead == 1) {
|
|
@@ -230,14 +237,48 @@ public class ITestS3AInputStreamPerformance extends S3AScaleTestBase {
|
|
|
remaining -= bytesRead;
|
|
|
offset += bytesRead;
|
|
|
count += bytesRead;
|
|
|
+ readTimer.end();
|
|
|
+ if (bytesRead != 0) {
|
|
|
+ LOG.debug("Bytes in read #{}: {} , block bytes: {}," +
|
|
|
+ " remaining in block: {}" +
|
|
|
+ " duration={} nS; ns/byte: {}, bandwidth={} MB/s",
|
|
|
+ reads, bytesRead, blockSize - remaining, remaining,
|
|
|
+ readTimer.duration(),
|
|
|
+ readTimer.nanosPerOperation(bytesRead),
|
|
|
+ readTimer.bandwidthDescription(bytesRead));
|
|
|
+ } else {
|
|
|
+ LOG.warn("0 bytes returned by read() operation #{}", reads);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ blockTimer.end("Reading block %d in %d reads", blockId, reads);
|
|
|
+ String bw = blockTimer.bandwidthDescription(blockSize);
|
|
|
+ LOG.info("Bandwidth of block {}: {} MB/s: ", blockId, bw);
|
|
|
+ if (bandwidth(blockTimer, blockSize) < minimumBandwidth) {
|
|
|
+ LOG.warn("Bandwidth {} too low on block {}: resetting connection",
|
|
|
+ bw, blockId);
|
|
|
+ Assert.assertTrue("Bandwidth of " + bw +" too low after "
|
|
|
+ + resetCount + " attempts", resetCount <= maxResetCount);
|
|
|
+ resetCount++;
|
|
|
+ // reset the connection
|
|
|
+ getS3AInputStream(in).resetConnection();
|
|
|
}
|
|
|
- blockTimer.end("Reading block %d in %d reads", i, reads);
|
|
|
}
|
|
|
- timer2.end("Time to read %d bytes in %d blocks", len, blockCount);
|
|
|
- bandwidth(timer2, count);
|
|
|
+ timer2.end("Time to read %d bytes in %d blocks", totalToRead, blockCount);
|
|
|
+ LOG.info("Overall Bandwidth {} MB/s; reset connections {}",
|
|
|
+ timer2.bandwidth(totalToRead), resetCount);
|
|
|
logStreamStatistics();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Work out the bandwidth in bytes/second.
|
|
|
+ * @param timer timer measuring the duration
|
|
|
+ * @param bytes bytes
|
|
|
+ * @return the number of bytes/second of the recorded operation
|
|
|
+ */
|
|
|
+ public static double bandwidth(NanoTimer timer, long bytes) {
|
|
|
+ return bytes * 1.0e9 / timer.duration();
|
|
|
+ }
|
|
|
+
|
|
|
@Test
|
|
|
public void testLazySeekEnabled() throws Throwable {
|
|
|
describe("Verify that seeks do not trigger any IO");
|