Skip to content

Commit cfe0181

Browse files
Googlercopybara-github
Googler
authored andcommitted
Remove BasicFilesystemDirtinessChecker in favor of UnionDirtinessChecker.
PiperOrigin-RevId: 529817592 Change-Id: I89f2e4293388fce72c7f9a91a4fdcc08e6c5eb69
1 parent 2c9a8d8 commit cfe0181

File tree

4 files changed

+27
-31
lines changed

4 files changed

+27
-31
lines changed

src/main/java/com/google/devtools/build/lib/skyframe/DirtinessCheckerUtils.java

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -79,49 +79,39 @@ public SkyValue createNewValue(
7979
}
8080
}
8181

82-
/** Checks dirtiness of filesystem keys in the graph. */
83-
public static class BasicFilesystemDirtinessChecker extends SkyValueDirtinessChecker {
84-
private final FileDirtinessChecker fdc = new FileDirtinessChecker();
85-
private final DirectoryDirtinessChecker ddc = new DirectoryDirtinessChecker();
86-
private final UnionDirtinessChecker checker =
87-
new UnionDirtinessChecker(ImmutableList.of(fdc, ddc));
88-
89-
@Override
90-
public boolean applies(SkyKey skyKey) {
91-
return fdc.applies(skyKey) || ddc.applies(skyKey);
92-
}
93-
94-
@Override
95-
@Nullable
96-
public SkyValue createNewValue(
97-
SkyKey key, SyscallCache syscallCache, @Nullable TimestampGranularityMonitor tsgm) {
98-
return checker.createNewValue(key, syscallCache, tsgm);
99-
}
100-
}
101-
102-
static final class MissingDiffDirtinessChecker extends BasicFilesystemDirtinessChecker {
82+
static final class MissingDiffDirtinessChecker extends SkyValueDirtinessChecker {
10383
private final Set<Root> missingDiffPackageRoots;
84+
private final UnionDirtinessChecker checker = createBasicFilesystemDirtinessChecker();
10485

10586
MissingDiffDirtinessChecker(Set<Root> missingDiffPackageRoots) {
10687
this.missingDiffPackageRoots = missingDiffPackageRoots;
10788
}
10889

10990
@Override
11091
public boolean applies(SkyKey key) {
111-
return super.applies(key)
92+
return checker.applies(key)
11293
&& missingDiffPackageRoots.contains(((RootedPath) key.argument()).getRoot());
11394
}
95+
96+
@Nullable
97+
@Override
98+
public SkyValue createNewValue(
99+
SkyKey key, SyscallCache syscallCache, @Nullable TimestampGranularityMonitor tsgm) {
100+
return checker.createNewValue(key, syscallCache, tsgm);
101+
}
114102
}
115103

116104
/**
117105
* Serves for tracking whether there are external and output files {@see ExternalFilesKnowledge}.
118106
* Filtering of files, for which the new values should not be injected into evaluator, is done in
119107
* SequencedSkyframeExecutor.handleChangedFiles().
120108
*/
121-
static final class ExternalDirtinessChecker extends BasicFilesystemDirtinessChecker {
109+
static final class ExternalDirtinessChecker extends SkyValueDirtinessChecker {
122110
private final ExternalFilesHelper externalFilesHelper;
123111
private final EnumSet<FileType> fileTypesToCheck;
124112

113+
private final UnionDirtinessChecker checker = createBasicFilesystemDirtinessChecker();
114+
125115
ExternalDirtinessChecker(ExternalFilesHelper externalFilesHelper,
126116
EnumSet<FileType> fileTypesToCheck) {
127117
this.externalFilesHelper = externalFilesHelper;
@@ -130,7 +120,7 @@ static final class ExternalDirtinessChecker extends BasicFilesystemDirtinessChec
130120

131121
@Override
132122
public boolean applies(SkyKey key) {
133-
if (!super.applies(key)) {
123+
if (!checker.applies(key)) {
134124
return false;
135125
}
136126
FileType fileType = externalFilesHelper.getAndNoteFileType((RootedPath) key.argument());
@@ -153,7 +143,7 @@ public SkyValueDirtinessChecker.DirtyResult check(
153143
FileType fileType = externalFilesHelper.getAndNoteFileType((RootedPath) skyKey.argument());
154144
boolean cacheable = isCacheableType(fileType);
155145
SkyValue newValue =
156-
super.createNewValue(skyKey, cacheable ? syscallCache : SyscallCache.NO_CACHE, tsgm);
146+
checker.createNewValue(skyKey, cacheable ? syscallCache : SyscallCache.NO_CACHE, tsgm);
157147
if (Objects.equal(newValue, oldValue)) {
158148
return SkyValueDirtinessChecker.DirtyResult.notDirty();
159149
}
@@ -180,6 +170,11 @@ private static boolean isCacheableType(FileType fileType) {
180170
}
181171
}
182172

173+
static UnionDirtinessChecker createBasicFilesystemDirtinessChecker() {
174+
return new UnionDirtinessChecker(
175+
ImmutableList.of(new FileDirtinessChecker(), new DirectoryDirtinessChecker()));
176+
}
177+
183178
/** {@link SkyValueDirtinessChecker} that encompasses a union of other dirtiness checkers. */
184179
public static final class UnionDirtinessChecker extends SkyValueDirtinessChecker {
185180
private final Iterable<SkyValueDirtinessChecker> dirtinessCheckers;

src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@
183183
import com.google.devtools.build.lib.skyframe.BuildDriverFunction.ActionLookupValuesCollectionResult;
184184
import com.google.devtools.build.lib.skyframe.BuildDriverFunction.TransitiveActionLookupValuesHelper;
185185
import com.google.devtools.build.lib.skyframe.DiffAwarenessManager.ProcessableModifiedFileSet;
186-
import com.google.devtools.build.lib.skyframe.DirtinessCheckerUtils.BasicFilesystemDirtinessChecker;
187186
import com.google.devtools.build.lib.skyframe.DirtinessCheckerUtils.ExternalDirtinessChecker;
188187
import com.google.devtools.build.lib.skyframe.DirtinessCheckerUtils.MissingDiffDirtinessChecker;
189188
import com.google.devtools.build.lib.skyframe.DirtinessCheckerUtils.UnionDirtinessChecker;
@@ -2246,7 +2245,9 @@ protected void invalidateFilesUnderPathForTestingImpl(
22462245
if (modifiedFileSet.treatEverythingAsModified()) {
22472246
diff =
22482247
new FilesystemValueChecker(tsgm, syscallCache, /* numThreads= */ 200)
2249-
.getDirtyKeys(memoizingEvaluator.getValues(), new BasicFilesystemDirtinessChecker());
2248+
.getDirtyKeys(
2249+
memoizingEvaluator.getValues(),
2250+
DirtinessCheckerUtils.createBasicFilesystemDirtinessChecker());
22502251
} else {
22512252
diff = getDiff(tsgm, modifiedFileSet, pathEntry, /* fsvcThreads= */ 200);
22522253
}

src/test/java/com/google/devtools/build/lib/skyframe/FilesystemValueCheckerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
import com.google.devtools.build.lib.io.FileSymlinkInfiniteExpansionUniquenessFunction;
5656
import com.google.devtools.build.lib.packages.WorkspaceFileValue;
5757
import com.google.devtools.build.lib.pkgcache.PathPackageLocator;
58-
import com.google.devtools.build.lib.skyframe.DirtinessCheckerUtils.BasicFilesystemDirtinessChecker;
5958
import com.google.devtools.build.lib.skyframe.ExternalFilesHelper.ExternalFileAction;
6059
import com.google.devtools.build.lib.skyframe.FilesystemValueChecker.ModifiedOutputsReceiver;
6160
import com.google.devtools.build.lib.skyframe.PackageFunction.GlobbingStrategy;
@@ -1759,6 +1758,7 @@ public long getNodeId() throws IOException {
17591758

17601759
private static Diff getDirtyFilesystemKeys(
17611760
MemoizingEvaluator evaluator, FilesystemValueChecker checker) throws InterruptedException {
1762-
return checker.getDirtyKeys(evaluator.getValues(), new BasicFilesystemDirtinessChecker());
1761+
return checker.getDirtyKeys(
1762+
evaluator.getValues(), DirtinessCheckerUtils.createBasicFilesystemDirtinessChecker());
17631763
}
17641764
}

src/test/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@
108108
import com.google.devtools.build.lib.server.FailureDetails.FailureDetail;
109109
import com.google.devtools.build.lib.server.FailureDetails.Spawn;
110110
import com.google.devtools.build.lib.server.FailureDetails.Spawn.Code;
111-
import com.google.devtools.build.lib.skyframe.DirtinessCheckerUtils.BasicFilesystemDirtinessChecker;
112111
import com.google.devtools.build.lib.skyframe.SkyframeActionExecutor.ActionCompletedReceiver;
113112
import com.google.devtools.build.lib.skyframe.SkyframeActionExecutor.ProgressSupplier;
114113
import com.google.devtools.build.lib.skyframe.TopLevelStatusEvents.TopLevelTargetBuiltEvent;
@@ -647,7 +646,8 @@ private ImmutableList<SkyKey> dirtyValues() throws InterruptedException {
647646
SyscallCache.NO_CACHE,
648647
/* numThreads= */ 20)
649648
.getDirtyKeys(
650-
skyframeExecutor.getEvaluator().getValues(), new BasicFilesystemDirtinessChecker());
649+
skyframeExecutor.getEvaluator().getValues(),
650+
DirtinessCheckerUtils.createBasicFilesystemDirtinessChecker());
651651
return ImmutableList.<SkyKey>builder()
652652
.addAll(diff.changedKeysWithoutNewValues())
653653
.addAll(diff.changedKeysWithNewValues().keySet())

0 commit comments

Comments
 (0)