Save remote output metadata to ActionCache and load them before checking action cache
This PR extends `ActionCache.Entry` to store output metadata by having a map of <Path, Metadata>. This map is updated after action execution when we update action cache so that metadata of all outputs of the action are saved. Before checking the action cache (when executing actions), we will load the output metadata into output store if it is remote and the correspondingly local one is missing.
With this change, remote output metadata is saved to disk so build without bytes can use them among server restarts.
We can also download outputs after action execution since remote output metadata can be accessed outside.
Part of https://github.com/bazelbuild/bazel/issues/12665.
Fixes https://github.com/bazelbuild/bazel/issues/8248.
Closes #13604.
PiperOrigin-RevId: 388586691
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/TreeArtifactValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/TreeArtifactValue.java
index 9b282bb..8590015 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/TreeArtifactValue.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/TreeArtifactValue.java
@@ -153,12 +153,12 @@
* metadata for it.
*/
@AutoValue
- abstract static class ArchivedRepresentation {
- abstract ArchivedTreeArtifact archivedTreeFileArtifact();
+ public abstract static class ArchivedRepresentation {
+ public abstract ArchivedTreeArtifact archivedTreeFileArtifact();
- abstract FileArtifactValue archivedFileValue();
+ public abstract FileArtifactValue archivedFileValue();
- static ArchivedRepresentation create(
+ public static ArchivedRepresentation create(
ArchivedTreeArtifact archivedTreeFileArtifact, FileArtifactValue fileArtifactValue) {
return new AutoValue_TreeArtifactValue_ArchivedRepresentation(
archivedTreeFileArtifact, fileArtifactValue);
@@ -225,7 +225,7 @@
}
/** Return archived representation of the tree artifact (if present). */
- Optional<ArchivedRepresentation> getArchivedRepresentation() {
+ public Optional<ArchivedRepresentation> getArchivedRepresentation() {
return Optional.ofNullable(archivedRepresentation);
}
@@ -304,7 +304,8 @@
* A TreeArtifactValue that represents a missing TreeArtifact. This is occasionally useful because
* Java's concurrent collections disallow null members.
*/
- static final TreeArtifactValue MISSING_TREE_ARTIFACT = createMarker("MISSING_TREE_ARTIFACT");
+ public static final TreeArtifactValue MISSING_TREE_ARTIFACT =
+ createMarker("MISSING_TREE_ARTIFACT");
private static TreeArtifactValue createMarker(String toStringRepresentation) {
return new TreeArtifactValue(
@@ -488,7 +489,7 @@
ArchivedRepresentation.create(archivedTreeArtifact, metadata));
}
- private Builder setArchivedRepresentation(ArchivedRepresentation archivedRepresentation) {
+ public Builder setArchivedRepresentation(ArchivedRepresentation archivedRepresentation) {
checkState(
this.archivedRepresentation == null,
"Tried to add 2 archived representations for: %s",