diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/cpp/blaze_util_posix.cc | 14 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java | 15 |
2 files changed, 9 insertions, 20 deletions
diff --git a/src/main/cpp/blaze_util_posix.cc b/src/main/cpp/blaze_util_posix.cc index 947faba021..139fc21ade 100644 --- a/src/main/cpp/blaze_util_posix.cc +++ b/src/main/cpp/blaze_util_posix.cc @@ -622,7 +622,7 @@ uint64_t AcquireLock(const string& output_base, bool batch_mode, bool block, // ones) mention that the Blaze invocation hangs on a non-existent PID. This // should help troubleshoot those scenarios in case there really is a bug // somewhere. - size_t attempts = 0; + bool multiple_attempts = false; string owner; const uint64_t start_time = GetMillisecondsMonotonic(); while (setlk(lockfd, &lock) == -1) { @@ -636,13 +636,10 @@ uint64_t AcquireLock(const string& output_base, bool batch_mode, bool block, if (owner != buffer) { // Each time we learn a new lock owner, print it out. owner = buffer; - if (attempts > 0) { - fprintf(stderr, " client lock owner changed\n"); - } fprintf(stderr, "Another command holds the client lock: \n%s\n", owner.c_str()); if (block) { - fprintf(stderr, "Waiting for it to complete..."); + fprintf(stderr, "Waiting for it to complete...\n"); fflush(stderr); } } @@ -653,10 +650,7 @@ uint64_t AcquireLock(const string& output_base, bool batch_mode, bool block, } TrySleep(500); - attempts += 1; - } - if (attempts > 0) { - fprintf(stderr, " done!\n"); + multiple_attempts = true; } const uint64_t end_time = GetMillisecondsMonotonic(); @@ -664,7 +658,7 @@ uint64_t AcquireLock(const string& output_base, bool batch_mode, bool block, // avoid unnecessary noise in the logs. In this metric, we are only // interested in knowing how long it took for other commands to complete, not // how fast acquiring a lock is. - const uint64_t wait_time = attempts == 0 ? 0 : end_time - start_time; + const uint64_t wait_time = !multiple_attempts ? 0 : end_time - start_time; // Identify ourselves in the lockfile. // The contents are printed for human consumption when another client diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java index 7653fd892f..0cab34771d 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java @@ -175,7 +175,7 @@ public class BlazeCommandDispatcher { // holding the lock has changed under the hood. There have been multiple bug reports where // users (especially macOS ones) mention that the Blaze invocation hangs on a non-existent PID. // This should help troubleshoot those scenarios in case there really is a bug somewhere. - int attempts = 0; + boolean multipleAttempts = false; long clockBefore = BlazeClock.nanoTime(); String otherClientDescription = ""; synchronized (commandLock) { @@ -183,10 +183,7 @@ public class BlazeCommandDispatcher { switch (lockingMode) { case WAIT: if (!otherClientDescription.equals(currentClientDescription)) { - if (attempts > 0) { - outErr.printErrLn(" lock taken by another command"); - } - outErr.printErr("Another command (" + currentClientDescription + ") is running. " + outErr.printErrLn("Another command (" + currentClientDescription + ") is running. " + " Waiting for it to complete on the server..."); otherClientDescription = currentClientDescription; } @@ -202,18 +199,16 @@ public class BlazeCommandDispatcher { throw new IllegalStateException(); } - attempts += 1; + multipleAttempts = true; } Verify.verify(currentClientDescription == null); currentClientDescription = clientDescription; } - if (attempts > 0) { - outErr.printErrLn(" done!"); - } // If we took the lock on the first try, force the reported wait time to 0 to avoid unnecessary // noise in the logs. In this metric, we are only interested in knowing how long it took for // other commands to complete, not how fast acquiring a lock is. - long waitTimeInMs = attempts == 0 ? 0 : (BlazeClock.nanoTime() - clockBefore) / (1000L * 1000L); + long waitTimeInMs = + !multipleAttempts ? 0 : (BlazeClock.nanoTime() - clockBefore) / (1000L * 1000L); try { if (shutdownReason != null) { |