Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,7 @@ public DependencyInfoConverter() {
private ActionDumpWriter writer;
private CommandEnvironment env;
private WalkableGraph graph;
private NanosToMillisSinceEpochConverter nanosToMillis =
BlazeClock.createNanosToMillisSinceEpochConverter();
private NanosToMillisSinceEpochConverter nanosToMillis;
// Only relevant for Skymeld: there may be multiple events and we only count the first one.
private final AtomicBoolean executionStarted = new AtomicBoolean();

Expand All @@ -210,13 +209,20 @@ void setGraph(WalkableGraph graph) {
}

@VisibleForTesting
void setNanosToMillis(NanosToMillisSinceEpochConverter nanosToMillis) {
this.nanosToMillis = nanosToMillis;
void resetNanosToMillis() {
this.nanosToMillis = BlazeClock.createNanosToMillisSinceEpochConverter();
}

@VisibleForTesting
NanosToMillisSinceEpochConverter getNanosToMillis() {
return nanosToMillis;
}

@Override
public void beforeCommand(CommandEnvironment env) {
this.env = env;
// The offset between monotonic and wall clock time may change between commands.
resetNanosToMillis();

if (env.getCommand().buildPhase().executes()) {
ExecutionGraphOptions options =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
import com.google.devtools.build.lib.buildtool.BuildResult;
import com.google.devtools.build.lib.buildtool.BuildResult.BuildToolLogCollection;
import com.google.devtools.build.lib.buildtool.buildevent.BuildCompleteEvent;
import com.google.devtools.build.lib.clock.BlazeClock;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.collect.nestedset.Order;
import com.google.devtools.build.lib.exec.util.FakeActionInputFileCache;
Expand Down Expand Up @@ -96,6 +95,7 @@ public class ExecutionGraphModuleTest extends FoundationTestCase {
@Before
public void createModule() {
module = new ExecutionGraphModule();
module.resetNanosToMillis();
}

@Before
Expand Down Expand Up @@ -671,8 +671,6 @@ public void spawnAndAction_withSameOutputs() throws Exception {
public void spawnAndAction_withDifferentOutputs() throws Exception {
var buffer = new ByteArrayOutputStream();
startLogging(eventBus, UUID.randomUUID(), buffer, DependencyInfo.ALL);
var nanosToMillis = BlazeClock.createNanosToMillisSinceEpochConverter();
module.setNanosToMillis(nanosToMillis);

module.spawnExecuted(
new SpawnExecutedEvent(
Expand Down Expand Up @@ -705,7 +703,7 @@ public void spawnAndAction_withDifferentOutputs() throws Exception {
.setIndex(1)
.setMetrics(
ExecutionGraph.Metrics.newBuilder()
.setStartTimestampMillis(nanosToMillis.toEpochMillis(0)))
.setStartTimestampMillis(module.getNanosToMillis().toEpochMillis(0)))
.setRuleClass("dummy-kind")
.build());
}
Expand All @@ -714,8 +712,6 @@ public void spawnAndAction_withDifferentOutputs() throws Exception {
public void noSpawnAction_hasCorrectDuration() throws Exception {
var buffer = new ByteArrayOutputStream();
startLogging(eventBus, UUID.randomUUID(), buffer, DependencyInfo.ALL);
var nanosToMillis = BlazeClock.createNanosToMillisSinceEpochConverter();
module.setNanosToMillis(nanosToMillis);

var action = new ActionsTestUtil.NullAction(createOutputArtifact("foo/out"));
module.actionComplete(
Expand All @@ -727,7 +723,7 @@ public void noSpawnAction_hasCorrectDuration() throws Exception {
executionGraphNodeBuilderForAction(action)
.setMetrics(
ExecutionGraph.Metrics.newBuilder()
.setStartTimestampMillis(nanosToMillis.toEpochMillis(1000000))
.setStartTimestampMillis(module.getNanosToMillis().toEpochMillis(1000000))
.setDurationMillis(1)
.setProcessMillis(1))
.setRuleClass("dummy-kind")
Expand Down