Move information whether the build is using in-memory action file system from `ActionExecutedEvent` to `BuildStartingEvent`.
A build will either use in-memory file system for all actions or none. Move the indicator for this from `ActionExecutedEvent` to `BuildStartingEvent` so that subscibers can note that information when execution starts and use it when receiving events. This way, we can take advantage of this information for other kinds of events.
PiperOrigin-RevId: 453749440
Change-Id: I15dfab0a4af492cbd847dab419f3e13508a2556f
diff --git a/src/main/java/com/google/devtools/build/lib/actions/ActionExecutedEvent.java b/src/main/java/com/google/devtools/build/lib/actions/ActionExecutedEvent.java
index b5c3d62..6510d17 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/ActionExecutedEvent.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/ActionExecutedEvent.java
@@ -52,7 +52,6 @@
private final Path stdout;
private final Path stderr;
private final ImmutableList<MetadataLog> actionMetadataLogs;
- private final boolean isInMemoryFs;
private final ErrorTiming timing;
public ActionExecutedEvent(
@@ -65,8 +64,7 @@
Path stdout,
Path stderr,
ImmutableList<MetadataLog> actionMetadataLogs,
- ErrorTiming timing,
- boolean isInMemoryFs) {
+ ErrorTiming timing) {
this.actionId = actionId;
this.action = action;
this.exception = exception;
@@ -77,7 +75,6 @@
this.stderr = stderr;
this.timing = timing;
this.actionMetadataLogs = actionMetadataLogs;
- this.isInMemoryFs = isInMemoryFs;
Preconditions.checkNotNull(this.actionMetadataLogs, this);
Preconditions.checkState(
(this.exception == null) == (this.timing == ErrorTiming.NO_ERROR), this);
@@ -98,10 +95,6 @@
return timing;
}
- public boolean hasInMemoryFs() {
- return isInMemoryFs;
- }
-
public String getStdout() {
if (stdout == null) {
return null;
diff --git a/src/main/java/com/google/devtools/build/lib/buildtool/buildevent/BuildStartingEvent.java b/src/main/java/com/google/devtools/build/lib/buildtool/buildevent/BuildStartingEvent.java
index f739e93..dee499b 100644
--- a/src/main/java/com/google/devtools/build/lib/buildtool/buildevent/BuildStartingEvent.java
+++ b/src/main/java/com/google/devtools/build/lib/buildtool/buildevent/BuildStartingEvent.java
@@ -42,6 +42,12 @@
/** Returns the name of output file system. */
public abstract String outputFileSystem();
+ /**
+ * Returns whether the build uses in-memory {@link
+ * com.google.devtools.build.lib.vfs.OutputService.ActionFileSystemType#inMemoryFileSystem()}.
+ */
+ public abstract boolean usesInMemoryFileSystem();
+
/** Returns the active BuildRequest. */
public abstract BuildRequest request();
@@ -59,6 +65,8 @@
public static BuildStartingEvent create(CommandEnvironment env, BuildRequest request) {
return create(
env.determineOutputFileSystem(),
+ env.getOutputService() != null
+ && env.getOutputService().actionFileSystemType().inMemoryFileSystem(),
request,
env.getDirectories().getWorkspace() != null
? env.getDirectories().getWorkspace().toString()
@@ -68,8 +76,13 @@
@VisibleForTesting
public static BuildStartingEvent create(
- String outputFileSystem, BuildRequest request, @Nullable String workspace, String pwd) {
- return new AutoValue_BuildStartingEvent(outputFileSystem, request, workspace, pwd);
+ String outputFileSystem,
+ boolean usesInMemoryFileSystem,
+ BuildRequest request,
+ @Nullable String workspace,
+ String pwd) {
+ return new AutoValue_BuildStartingEvent(
+ outputFileSystem, usesInMemoryFileSystem, request, workspace, pwd);
}
@Override
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java
index 9bb7461..5cd3034 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java
@@ -1220,7 +1220,6 @@
/*primaryOutputMetadata=*/ null,
action,
actionResult,
- actionFileSystemType().inMemoryFileSystem(),
actionException,
fileOutErr,
ErrorTiming.AFTER_EXECUTION);
@@ -1233,7 +1232,6 @@
/*primaryOutputMetadata=*/ null,
action,
actionResult,
- actionFileSystemType().inMemoryFileSystem(),
new ActionExecutionException(
exception,
action,
@@ -1260,7 +1258,6 @@
primaryOutputMetadata,
action,
actionResult,
- actionFileSystemType().inMemoryFileSystem(),
null,
fileOutErr,
ErrorTiming.NO_ERROR);
@@ -1413,7 +1410,6 @@
/*primaryOutputMetadata=*/ null,
action,
null,
- actionFileSystemType().inMemoryFileSystem(),
e,
outErrBuffer,
errorTiming);
@@ -1694,7 +1690,6 @@
@Nullable FileArtifactValue primaryOutputMetadata,
Action action,
@Nullable ActionResult actionResult,
- boolean isInMemoryFs,
ActionExecutionException exception,
FileOutErr outErr,
ErrorTiming errorTiming) {
@@ -1726,8 +1721,7 @@
stdout,
stderr,
logs,
- errorTiming,
- isInMemoryFs));
+ errorTiming));
}
/** An object supplying data for action execution progress reporting. */
diff --git a/src/test/java/com/google/devtools/build/lib/runtime/BuildEventStreamerTest.java b/src/test/java/com/google/devtools/build/lib/runtime/BuildEventStreamerTest.java
index ee504e5..6fc94eb 100644
--- a/src/test/java/com/google/devtools/build/lib/runtime/BuildEventStreamerTest.java
+++ b/src/test/java/com/google/devtools/build/lib/runtime/BuildEventStreamerTest.java
@@ -150,8 +150,7 @@
/*stdout=*/ null,
/*stderr=*/ null,
/*actionMetadataLogs=*/ ImmutableList.of(),
- ErrorTiming.NO_ERROR,
- /*isInMemoryFs=*/ false);
+ ErrorTiming.NO_ERROR);
private static final class RecordingBuildEventTransport implements BuildEventTransport {
private final List<BuildEvent> events = new ArrayList<>();
@@ -1257,8 +1256,7 @@
/*stdout=*/ null,
/*stderr=*/ null,
/*actionMetadataLogs=*/ ImmutableList.of(),
- ErrorTiming.BEFORE_EXECUTION,
- /*isInMemoryFs=*/ false);
+ ErrorTiming.BEFORE_EXECUTION);
streamer.buildEvent(SUCCESSFUL_ACTION_EXECUTED_EVENT);
streamer.buildEvent(failedActionExecutedEvent);
@@ -1302,8 +1300,7 @@
/*stdout=*/ null,
/*stderr=*/ null,
/*actionMetadataLogs=*/ ImmutableList.of(),
- ErrorTiming.BEFORE_EXECUTION,
- /*isInMemoryFs=*/ false);
+ ErrorTiming.BEFORE_EXECUTION);
streamer.buildEvent(SUCCESSFUL_ACTION_EXECUTED_EVENT);
streamer.buildEvent(failedActionExecutedEvent);
@@ -1516,8 +1513,7 @@
/*stdout=*/ null,
/*stderr=*/ null,
metadataLogs,
- ErrorTiming.NO_ERROR,
- /*isInMemoryFs=*/ false);
+ ErrorTiming.NO_ERROR);
}
@Test
diff --git a/src/test/java/com/google/devtools/build/lib/runtime/UiEventHandlerStdOutAndStdErrTest.java b/src/test/java/com/google/devtools/build/lib/runtime/UiEventHandlerStdOutAndStdErrTest.java
index b24d074..e6b2dee 100644
--- a/src/test/java/com/google/devtools/build/lib/runtime/UiEventHandlerStdOutAndStdErrTest.java
+++ b/src/test/java/com/google/devtools/build/lib/runtime/UiEventHandlerStdOutAndStdErrTest.java
@@ -82,7 +82,11 @@
new UiEventHandler(outErr, uiOptions, new ManualClock(), /*workspacePathFragment=*/ null);
uiEventHandler.buildStarted(
BuildStartingEvent.create(
- "outputFileSystemType", mock(BuildRequest.class), /*workspace=*/ null, "/pwd"));
+ "outputFileSystemType",
+ /*usesInMemoryFileSystem=*/ false,
+ mock(BuildRequest.class),
+ /*workspace=*/ null,
+ "/pwd"));
}
@Test