aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Austin Schuh <austin.linux@gmail.com>2017-11-30 04:47:36 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2017-11-30 04:49:11 -0800
commitbdf8354790a23884c8e888c6b158d73f8d57e461 (patch)
tree4eadab68196f52f3a0e058173257a2c6d9a9b854
parent1df4635d2c790f555aeb20e6c43b30ea77a14c80 (diff)
Take MB/s into account for the Slow read message.
Slow read: a 1253924941-byte read from image.tar.gz took 5396ms. is 221 MB/s, which is smokin' fast, not slow :P Fixes: #3967 Change-Id: Ieca7464e0a670ade52f80172408334c9fc3a5b52 PiperOrigin-RevId: 177438364
-rw-r--r--src/main/java/com/google/devtools/build/lib/actions/cache/DigestUtils.java9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/actions/cache/DigestUtils.java b/src/main/java/com/google/devtools/build/lib/actions/cache/DigestUtils.java
index 1c5b1e35c8..b3adbd8800 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/cache/DigestUtils.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/cache/DigestUtils.java
@@ -58,6 +58,13 @@ public class DigestUtils {
private static final Object DIGEST_LOCK = new Object();
private static final AtomicBoolean MULTI_THREADED_DIGEST = new AtomicBoolean(false);
+ // The time that a digest computation has to take at least in order to be considered a slow-read.
+ private static final long SLOW_READ_MILLIS = 5000L;
+
+ // The average bytes-per-millisecond throughput that a digest computation has to go below in order
+ // to be considered a slow-read.
+ private static final long SLOW_READ_THROUGHPUT = (10 * 1024 * 1024) / 1000;
+
/**
* Keys used to cache the values of the digests for files where we don't have fast digests.
*
@@ -151,7 +158,7 @@ public class DigestUtils {
byte[] digest = path.getDigest();
long millis = (BlazeClock.nanoTime() - startTime) / 1000000;
- if (millis > 5000L) {
+ if (millis > SLOW_READ_MILLIS && (path.getFileSize() / millis) < SLOW_READ_THROUGHPUT) {
System.err.println("Slow read: a " + path.getFileSize() + "-byte read from " + path
+ " took " + millis + "ms.");
}