From f45c22407e6b00fcba706eb62141cb9036bd38d7 Mon Sep 17 00:00:00 2001 From: lberki Date: Mon, 2 Jul 2018 02:44:51 -0700 Subject: Set the start time of binary and JSON profiles to zero correctly. Also correct for buggy profiles written previously. RELNOTES: None. PiperOrigin-RevId: 202920255 --- .../devtools/build/lib/profiler/analysis/ProfileInfo.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/main/java/com/google/devtools/build/lib/profiler/analysis') diff --git a/src/main/java/com/google/devtools/build/lib/profiler/analysis/ProfileInfo.java b/src/main/java/com/google/devtools/build/lib/profiler/analysis/ProfileInfo.java index 5050eb4436..4eb7f6e115 100644 --- a/src/main/java/com/google/devtools/build/lib/profiler/analysis/ProfileInfo.java +++ b/src/main/java/com/google/devtools/build/lib/profiler/analysis/ProfileInfo.java @@ -444,6 +444,7 @@ public class ProfileInfo { private static final AggregateAttr ZERO = new AggregateAttr(0, 0); public final String comment; + private long minTaskStartTime = Long.MAX_VALUE; private boolean corruptedOrIncomplete = false; // TODO(bazel-team): (2010) In one case, this list took 277MB of heap. Ideally it should be @@ -475,6 +476,7 @@ public class ProfileInfo { private void addTask(Task task) { allTasksById.add(task); + minTaskStartTime = Math.min(minTaskStartTime, task.startTime); } /** @@ -624,6 +626,16 @@ public class ProfileInfo { return new AggregateAttr(count, totalTime); } + /** + * Returns the minimum task start time, that is, when the profile actually started. + * + *

This should be very close to zero except that some Blaze versions contained a bug that made + * them not subtract the current time from task start times in the profile.

+ */ + public long getMinTaskStartTime() { + return minTaskStartTime; + } + /** * Returns list of all root tasks related to (in other words, started during) * the specified phase task. -- cgit v1.2.3