Skip to content

Commit f62a8b9

Browse files
coeuvrecopybara-github
authored andcommitted
Remove actionId from RemoteFileArtifactValue.
actionId was added by #11236 to track download requests for input prefetches. However, according to the REAPI spec, action_id is > An identifier that ties multiple requests to the same action. For example, multiple requests to the CAS, Action Cache, and Execution API are used in order to compile foo.cc. The input prefetches are requested by local actions that depend on outputs of remote executed action (which is identified by the action_id). These requests are not part of generating action hence shouldn't be bound with the action_id. We could include ActionExecutionMetadata of the local action for the requests for the tracking purpose, but that desires another CL. PiperOrigin-RevId: 510430853 Change-Id: I8d64a4f7033320a394e02a2b11498f09a3d15310
1 parent 8b49542 commit f62a8b9

13 files changed

+145
-185
lines changed

src/main/java/com/google/devtools/build/lib/actions/FileArtifactValue.java

Lines changed: 10 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,6 @@ public int getLocationIndex() {
109109
return 0;
110110
}
111111

112-
/**
113-
* Remote action source identifier for the file.
114-
*
115-
* <p>"" indicates that a remote action output was not the source of this artifact.
116-
*/
117-
public String getActionId() {
118-
return "";
119-
}
120-
121112
/** Returns {@code true} if the file only exists remotely. */
122113
public boolean isRemote() {
123114
return false;
@@ -551,35 +542,27 @@ public static class RemoteFileArtifactValue extends FileArtifactValue {
551542
protected final byte[] digest;
552543
protected final long size;
553544
protected final int locationIndex;
554-
protected final String actionId;
555545

556-
private RemoteFileArtifactValue(byte[] digest, long size, int locationIndex, String actionId) {
557-
this.digest = Preconditions.checkNotNull(digest, actionId);
546+
private RemoteFileArtifactValue(byte[] digest, long size, int locationIndex) {
547+
this.digest = Preconditions.checkNotNull(digest);
558548
this.size = size;
559549
this.locationIndex = locationIndex;
560-
this.actionId = actionId;
561-
}
562-
563-
public static RemoteFileArtifactValue create(
564-
byte[] digest, long size, int locationIndex, String actionId) {
565-
return new RemoteFileArtifactValue(digest, size, locationIndex, actionId);
566550
}
567551

568552
public static RemoteFileArtifactValue create(byte[] digest, long size, int locationIndex) {
569-
return new RemoteFileArtifactValue(digest, size, locationIndex, /* actionId= */ "");
553+
return new RemoteFileArtifactValue(digest, size, locationIndex);
570554
}
571555

572556
public static RemoteFileArtifactValue create(
573557
byte[] digest,
574558
long size,
575559
int locationIndex,
576-
String actionId,
577560
@Nullable PathFragment materializationExecPath) {
578561
if (materializationExecPath != null) {
579562
return new RemoteFileArtifactValueWithMaterializationPath(
580-
digest, size, locationIndex, actionId, materializationExecPath);
563+
digest, size, locationIndex, materializationExecPath);
581564
}
582-
return new RemoteFileArtifactValue(digest, size, locationIndex, actionId);
565+
return new RemoteFileArtifactValue(digest, size, locationIndex);
583566
}
584567

585568
@Override
@@ -591,13 +574,12 @@ public boolean equals(Object o) {
591574
RemoteFileArtifactValue that = (RemoteFileArtifactValue) o;
592575
return Arrays.equals(digest, that.digest)
593576
&& size == that.size
594-
&& locationIndex == that.locationIndex
595-
&& Objects.equals(actionId, that.actionId);
577+
&& locationIndex == that.locationIndex;
596578
}
597579

598580
@Override
599581
public int hashCode() {
600-
return Objects.hash(Arrays.hashCode(digest), size, locationIndex, actionId);
582+
return Objects.hash(Arrays.hashCode(digest), size, locationIndex);
601583
}
602584

603585
@Override
@@ -620,11 +602,6 @@ public long getSize() {
620602
return size;
621603
}
622604

623-
@Override
624-
public String getActionId() {
625-
return actionId;
626-
}
627-
628605
@Override
629606
public long getModifiedTime() {
630607
throw new UnsupportedOperationException(
@@ -652,7 +629,6 @@ public String toString() {
652629
.add("digest", bytesToString(digest))
653630
.add("size", size)
654631
.add("locationIndex", locationIndex)
655-
.add("actionId", actionId)
656632
.toString();
657633
}
658634
}
@@ -668,12 +644,8 @@ public static final class RemoteFileArtifactValueWithMaterializationPath
668644
private final PathFragment materializationExecPath;
669645

670646
private RemoteFileArtifactValueWithMaterializationPath(
671-
byte[] digest,
672-
long size,
673-
int locationIndex,
674-
String actionId,
675-
PathFragment materializationExecPath) {
676-
super(digest, size, locationIndex, actionId);
647+
byte[] digest, long size, int locationIndex, PathFragment materializationExecPath) {
648+
super(digest, size, locationIndex);
677649
this.materializationExecPath = Preconditions.checkNotNull(materializationExecPath);
678650
}
679651

@@ -693,14 +665,12 @@ public boolean equals(Object o) {
693665
return Arrays.equals(digest, that.digest)
694666
&& size == that.size
695667
&& locationIndex == that.locationIndex
696-
&& Objects.equals(actionId, that.actionId)
697668
&& Objects.equals(materializationExecPath, that.materializationExecPath);
698669
}
699670

700671
@Override
701672
public int hashCode() {
702-
return Objects.hash(
703-
Arrays.hashCode(digest), size, locationIndex, actionId, materializationExecPath);
673+
return Objects.hash(Arrays.hashCode(digest), size, locationIndex, materializationExecPath);
704674
}
705675

706676
@Override
@@ -709,7 +679,6 @@ public String toString() {
709679
.add("digest", bytesToString(digest))
710680
.add("size", size)
711681
.add("locationIndex", locationIndex)
712-
.add("actionId", actionId)
713682
.add("materializationExecPath", materializationExecPath)
714683
.toString();
715684
}

src/main/java/com/google/devtools/build/lib/actions/cache/CompactPersistentActionCache.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public class CompactPersistentActionCache implements ActionCache {
7676

7777
private static final int NO_INPUT_DISCOVERY_COUNT = -1;
7878

79-
private static final int VERSION = 14;
79+
private static final int VERSION = 15;
8080

8181
private static final class ActionMap extends PersistentMap<Integer, byte[]> {
8282
private final Clock clock;
@@ -466,8 +466,6 @@ private static void encodeRemoteMetadata(
466466

467467
VarInt.putVarInt(value.getLocationIndex(), sink);
468468

469-
VarInt.putVarInt(indexer.getOrCreateIndex(value.getActionId()), sink);
470-
471469
Optional<PathFragment> materializationExecPath = value.getMaterializationExecPath();
472470
if (materializationExecPath.isPresent()) {
473471
VarInt.putVarInt(1, sink);
@@ -491,8 +489,6 @@ private static RemoteFileArtifactValue decodeRemoteMetadata(
491489

492490
int locationIndex = VarInt.getVarInt(source);
493491

494-
String actionId = getStringForIndex(indexer, VarInt.getVarInt(source));
495-
496492
PathFragment materializationExecPath = null;
497493
int numMaterializationExecPath = VarInt.getVarInt(source);
498494
if (numMaterializationExecPath > 0) {
@@ -503,8 +499,7 @@ private static RemoteFileArtifactValue decodeRemoteMetadata(
503499
PathFragment.create(getStringForIndex(indexer, VarInt.getVarInt(source)));
504500
}
505501

506-
return RemoteFileArtifactValue.create(
507-
digest, size, locationIndex, actionId, materializationExecPath);
502+
return RemoteFileArtifactValue.create(digest, size, locationIndex, materializationExecPath);
508503
}
509504

510505
/** @return action data encoded as a byte[] array. */

src/main/java/com/google/devtools/build/lib/remote/RemoteActionFileSystem.java

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,11 @@ public void updateContext(MetadataInjector metadataInjector) {
114114
this.metadataInjector = metadataInjector;
115115
}
116116

117-
void injectRemoteFile(PathFragment path, byte[] digest, long size, String actionId)
118-
throws IOException {
117+
void injectRemoteFile(PathFragment path, byte[] digest, long size) throws IOException {
119118
if (!isOutput(path)) {
120119
return;
121120
}
122-
remoteOutputTree.injectRemoteFile(path, digest, size, actionId);
121+
remoteOutputTree.injectRemoteFile(path, digest, size);
123122
}
124123

125124
void flush() throws IOException {
@@ -206,7 +205,6 @@ private void maybeInjectMetadataForSymlink(PathFragment linkPath, Artifact outpu
206205
metadata.getDigest(),
207206
metadata.getSize(),
208207
metadata.getLocationIndex(),
209-
metadata.getActionId(),
210208
// Avoid a double indirection when the target is already materialized as a symlink.
211209
metadata.getMaterializationExecPath().orElse(targetPath.relativeTo(execRoot)));
212210

@@ -216,10 +214,7 @@ private void maybeInjectMetadataForSymlink(PathFragment linkPath, Artifact outpu
216214

217215
private RemoteFileArtifactValue createRemoteMetadata(RemoteFileInfo remoteFile) {
218216
return RemoteFileArtifactValue.create(
219-
remoteFile.getFastDigest(),
220-
remoteFile.getSize(),
221-
/* locationIndex= */ 1,
222-
remoteFile.getActionId());
217+
remoteFile.getFastDigest(), remoteFile.getSize(), /* locationIndex= */ 1);
223218
}
224219

225220
@Override
@@ -741,8 +736,7 @@ protected FileInfo newFile(Clock clock, PathFragment path) {
741736
return new RemoteFileInfo(clock);
742737
}
743738

744-
void injectRemoteFile(PathFragment path, byte[] digest, long size, String actionId)
745-
throws IOException {
739+
void injectRemoteFile(PathFragment path, byte[] digest, long size) throws IOException {
746740
createDirectoryAndParents(path.getParentDirectory());
747741
InMemoryContentInfo node = getOrCreateWritableInode(path);
748742
// If a node was already existed and is not a remote file node (i.e. directory or symlink node
@@ -752,7 +746,7 @@ void injectRemoteFile(PathFragment path, byte[] digest, long size, String action
752746
}
753747

754748
RemoteFileInfo remoteFileInfo = (RemoteFileInfo) node;
755-
remoteFileInfo.set(digest, size, actionId);
749+
remoteFileInfo.set(digest, size);
756750
}
757751

758752
@Nullable
@@ -769,16 +763,14 @@ static class RemoteFileInfo extends FileInfo {
769763

770764
private byte[] digest;
771765
private long size;
772-
private String actionId;
773766

774767
RemoteFileInfo(Clock clock) {
775768
super(clock);
776769
}
777770

778-
private void set(byte[] digest, long size, String actionId) {
771+
private void set(byte[] digest, long size) {
779772
this.digest = digest;
780773
this.size = size;
781-
this.actionId = actionId;
782774
}
783775

784776
@Override
@@ -805,9 +797,5 @@ public byte[] getFastDigest() {
805797
public long getSize() {
806798
return size;
807799
}
808-
809-
public String getActionId() {
810-
return actionId;
811-
}
812800
}
813801
}

src/main/java/com/google/devtools/build/lib/remote/RemoteActionInputFetcher.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ protected ListenableFuture<Void> doDownloadFile(
9191
throws IOException {
9292
checkArgument(metadata.isRemote(), "Cannot download file that is not a remote file.");
9393
RequestMetadata requestMetadata =
94-
TracingMetadataUtils.buildMetadata(buildRequestId, commandId, metadata.getActionId(), null);
94+
TracingMetadataUtils.buildMetadata(buildRequestId, commandId, "prefetcher", null);
9595
RemoteActionExecutionContext context = RemoteActionExecutionContext.create(requestMetadata);
9696

9797
Digest digest = DigestUtil.buildDigest(metadata.getDigest(), metadata.getSize());

src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionService.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,6 @@ private void injectRemoteArtifacts(RemoteAction action, ActionResultMetadata met
793793
FileSystem actionFileSystem = action.getSpawnExecutionContext().getActionFileSystem();
794794
checkState(actionFileSystem instanceof RemoteActionFileSystem);
795795

796-
RemoteActionExecutionContext context = action.getRemoteActionExecutionContext();
797796
RemoteActionFileSystem remoteActionFileSystem = (RemoteActionFileSystem) actionFileSystem;
798797

799798
for (Map.Entry<Path, DirectoryMetadata> entry : metadata.directories()) {
@@ -808,17 +807,15 @@ private void injectRemoteArtifacts(RemoteAction action, ActionResultMetadata met
808807
remoteActionFileSystem.injectRemoteFile(
809808
file.path().asFragment(),
810809
DigestUtil.toBinaryDigest(file.digest()),
811-
file.digest().getSizeBytes(),
812-
context.getRequestMetadata().getActionId());
810+
file.digest().getSizeBytes());
813811
}
814812
}
815813

816814
for (FileMetadata file : metadata.files()) {
817815
remoteActionFileSystem.injectRemoteFile(
818816
file.path().asFragment(),
819817
DigestUtil.toBinaryDigest(file.digest()),
820-
file.digest().getSizeBytes(),
821-
context.getRequestMetadata().getActionId());
818+
file.digest().getSizeBytes());
822819
}
823820
}
824821

src/test/java/com/google/devtools/build/lib/actions/ActionCacheCheckerTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,7 @@ private RemoteFileArtifactValue createRemoteFileMetadata(String content) {
463463
private RemoteFileArtifactValue createRemoteFileMetadata(
464464
String content, @Nullable PathFragment materializationExecPath) {
465465
byte[] bytes = content.getBytes(UTF_8);
466-
return RemoteFileArtifactValue.create(
467-
digest(bytes), bytes.length, 1, "action-id", materializationExecPath);
466+
return RemoteFileArtifactValue.create(digest(bytes), bytes.length, 1, materializationExecPath);
468467
}
469468

470469
private static TreeArtifactValue createTreeMetadata(

src/test/java/com/google/devtools/build/lib/actions/cache/CompactPersistentActionCacheTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,7 @@ private RemoteFileArtifactValue createRemoteMetadata(
208208
.getHashFunction()
209209
.hashBytes(bytes)
210210
.asBytes();
211-
return RemoteFileArtifactValue.create(
212-
digest, bytes.length, 1, "action-id", materializationExecPath);
211+
return RemoteFileArtifactValue.create(digest, bytes.length, 1, materializationExecPath);
213212
}
214213

215214
private RemoteFileArtifactValue createRemoteMetadata(Artifact artifact, String content) {

src/test/java/com/google/devtools/build/lib/remote/ActionInputPrefetcherTestBase.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ protected Artifact createRemoteArtifact(
100100
hashCode.asBytes(),
101101
contentsBytes.length,
102102
/* locationIndex= */ 1,
103-
"action-id",
104103
materializationExecPath);
105104
metadata.put(a, f);
106105
cas.put(hashCode, contentsBytes);
@@ -134,7 +133,7 @@ protected Pair<SpecialArtifact, ImmutableList<TreeFileArtifact>> createRemoteTre
134133
TreeFileArtifact.createTreeOutput(parent, PathFragment.create(entry.getKey()));
135134
RemoteFileArtifactValue childValue =
136135
RemoteFileArtifactValue.create(
137-
hashCode.asBytes(), contentsBytes.length, /* locationIndex= */ 1, "action-id");
136+
hashCode.asBytes(), contentsBytes.length, /* locationIndex= */ 1);
138137
treeBuilder.putChild(child, childValue);
139138
metadata.put(child, childValue);
140139
cas.put(hashCode, contentsBytes);

src/test/java/com/google/devtools/build/lib/remote/ByteStreamBuildEventArtifactUploaderTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ private Artifact createRemoteArtifact(
442442
byte[] b = contents.getBytes(StandardCharsets.UTF_8);
443443
HashCode h = HashCode.fromString(DIGEST_UTIL.compute(b).getHash());
444444
FileArtifactValue f =
445-
RemoteFileArtifactValue.create(h.asBytes(), b.length, /* locationIndex= */ 1, "action-id");
445+
RemoteFileArtifactValue.create(h.asBytes(), b.length, /* locationIndex= */ 1);
446446
inputs.putWithNoDepOwner(a, f);
447447
return a;
448448
}
@@ -513,8 +513,6 @@ public ListenableFuture<ImmutableSet<Digest>> findMissingDigests(
513513

514514
private static class AllMissingDigestsFinder implements MissingDigestsFinder {
515515

516-
public static final AllMissingDigestsFinder INSTANCE = new AllMissingDigestsFinder();
517-
518516
@Override
519517
public ListenableFuture<ImmutableSet<Digest>> findMissingDigests(
520518
RemoteActionExecutionContext context, Iterable<Digest> digests) {

src/test/java/com/google/devtools/build/lib/remote/RemoteActionFileSystemTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ protected void injectRemoteFile(FileSystem actionFs, PathFragment path, String c
325325
byte[] contentBytes = content.getBytes(StandardCharsets.UTF_8);
326326
HashCode hashCode = HASH_FUNCTION.getHashFunction().hashBytes(contentBytes);
327327
((RemoteActionFileSystem) actionFs)
328-
.injectRemoteFile(path, hashCode.asBytes(), contentBytes.length, "action-id");
328+
.injectRemoteFile(path, hashCode.asBytes(), contentBytes.length);
329329
}
330330

331331
@Override
@@ -341,7 +341,7 @@ private Artifact createRemoteArtifact(
341341
byte[] b = contents.getBytes(StandardCharsets.UTF_8);
342342
HashCode h = HASH_FUNCTION.getHashFunction().hashBytes(b);
343343
RemoteFileArtifactValue f =
344-
RemoteFileArtifactValue.create(h.asBytes(), b.length, /* locationIndex= */ 1, "action-id");
344+
RemoteFileArtifactValue.create(h.asBytes(), b.length, /* locationIndex= */ 1);
345345
inputs.putWithNoDepOwner(a, f);
346346
return a;
347347
}
@@ -363,8 +363,7 @@ private TreeArtifactValue createRemoteTreeArtifactValue(
363363
byte[] b = entry.getValue().getBytes(StandardCharsets.UTF_8);
364364
HashCode h = HASH_FUNCTION.getHashFunction().hashBytes(b);
365365
RemoteFileArtifactValue childMeta =
366-
RemoteFileArtifactValue.create(
367-
h.asBytes(), b.length, /* locationIndex= */ 0, "action-id");
366+
RemoteFileArtifactValue.create(h.asBytes(), b.length, /* locationIndex= */ 0);
368367
builder.putChild(child, childMeta);
369368
}
370369
return builder.build();

0 commit comments

Comments
 (0)