TEZ-4026. Fetch Download rate shows 0.0 MB per second if duration is 0 millis
diff --git a/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/shuffle/ShuffleUtils.java b/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/shuffle/ShuffleUtils.java
index 1482a12..40909d4 100644
--- a/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/shuffle/ShuffleUtils.java
+++ b/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/shuffle/ShuffleUtils.java
@@ -567,15 +567,14 @@
if (activeLogger.isInfoEnabled()) {
long wholeMBs = 0;
long partialMBs = 0;
- if (millis != 0) {
- // fast math is done using integer math to avoid double to string conversion
- // calculate B/s * 100 to preserve MBs precision to two decimal places
- // multiply numerator by 100000 (2^5 * 5^5) and divide denominator by MB (2^20)
- // simply fraction to protect ourselves from overflow by factoring out 2^5
- wholeMBs = (bytesCompressed * 3125) / (millis * 32768);
- partialMBs = wholeMBs % 100;
- wholeMBs /= 100;
- }
+ millis = Math.max(1L, millis);
+ // fast math is done using integer math to avoid double to string conversion
+ // calculate B/s * 100 to preserve MBs precision to two decimal places
+ // multiply numerator by 100000 (2^5 * 5^5) and divide denominator by MB (2^20)
+ // simply fraction to protect ourselves from overflow by factoring out 2^5
+ wholeMBs = (bytesCompressed * 3125) / (millis * 32768);
+ partialMBs = wholeMBs % 100;
+ wholeMBs /= 100;
StringBuilder sb = new StringBuilder("Completed fetch for attempt: ");
toShortString(srcAttemptIdentifier, sb);
sb.append(" to ");