Skip to content

Commit

Permalink
Replace Duration with int-s in ExecutionGraphModule.java
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 525448490
Change-Id: I19830b40fd2abee9df3345489e272f8d68174452
  • Loading branch information
wilwell authored and fweikert committed May 25, 2023
1 parent ee81ed3 commit 9b3cf1a
Showing 1 changed file with 13 additions and 19 deletions.
Expand Up @@ -75,7 +75,6 @@
import com.google.protobuf.CodedOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.time.Duration;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
Expand Down Expand Up @@ -463,24 +462,22 @@ private ExecutionGraph.Node toProto(SpawnExecutedEvent event) {

SpawnMetrics metrics = spawnResult.getMetrics();
spawnResult = null;
long totalMillis = metrics.totalTimeInMs();
int totalMillis = metrics.totalTimeInMs();

long discoverInputsMillis = 0;
ActionInput firstOutput = getFirstOutput(spawn.getResourceOwner(), spawn.getOutputFiles());
Duration discoverInputsTime = outputToDiscoverInputsTime.get(firstOutput);
if (discoverInputsTime != null) {
Integer discoverInputsTimeInMs = outputToDiscoverInputsTimeMs.get(firstOutput);
if (discoverInputsTimeInMs != null) {
// Remove this so we don't count it again later, if an action has multiple spawns.
outputToDiscoverInputsTime.remove(firstOutput);
discoverInputsMillis = discoverInputsTime.toMillis();
totalMillis += discoverInputsMillis;
outputToDiscoverInputsTimeMs.remove(firstOutput);
totalMillis += discoverInputsTimeInMs;
}

ExecutionGraph.Metrics.Builder metricsBuilder =
ExecutionGraph.Metrics.newBuilder()
.setStartTimestampMillis(startMillis)
.setDurationMillis((int) totalMillis)
.setDurationMillis(totalMillis)
.setFetchMillis(metrics.fetchTimeInMs())
.setDiscoverInputsMillis((int) discoverInputsMillis)
.setDiscoverInputsMillis(discoverInputsTimeInMs != null ? discoverInputsTimeInMs : 0)
.setParseMillis(metrics.parseTimeInMs())
.setProcessMillis(metrics.executionWallTimeInMs())
.setQueueMillis(metrics.queueTimeInMs())
Expand Down Expand Up @@ -630,7 +627,8 @@ private NodeInfo(int index, long finishMs) {
private final boolean localLockFreeOutputEnabled;
private final boolean logFileWriteEdges;
private final Map<ActionInput, NodeInfo> outputToNode = new ConcurrentHashMap<>();
private final Map<ActionInput, Duration> outputToDiscoverInputsTime = new ConcurrentHashMap<>();
private final Map<ActionInput, Integer> outputToDiscoverInputsTimeMs =
new ConcurrentHashMap<>();
private final DependencyInfo depType;
private final AtomicInteger nextIndex = new AtomicInteger(0);

Expand Down Expand Up @@ -699,15 +697,11 @@ void enqueue(byte[] entry) {
void enqueue(DiscoveredInputsEvent event) {
// The other times from SpawnMetrics are not needed. The only instance of
// DiscoveredInputsEvent sets only total and parse time, and to the same value.
var totalTime = Duration.ofMillis(event.getMetrics().totalTimeInMs());
var totalTime = event.getMetrics().totalTimeInMs();
var firstOutput = getFirstOutput(event.getAction(), event.getAction().getOutputs());
var sum = outputToDiscoverInputsTime.get(firstOutput);
if (sum != null) {
sum = sum.plus(totalTime);
} else {
sum = totalTime;
}
outputToDiscoverInputsTime.put(firstOutput, sum);
var sum = outputToDiscoverInputsTimeMs.getOrDefault(firstOutput, 0);
sum += totalTime;
outputToDiscoverInputsTimeMs.put(firstOutput, sum);
}

void enqueue(Action action, long startMillis) {
Expand Down

0 comments on commit 9b3cf1a

Please sign in to comment.