Search in sources :

Example 1 with Diff

use of com.google.devtools.build.skyframe.Differencer.Diff in project bazel by bazelbuild.

the class FilesystemValueCheckerTest method testFileWithIOExceptionNotConsideredDirty.

@Test
public void testFileWithIOExceptionNotConsideredDirty() throws Exception {
    Path path = fs.getPath("/testroot/foo");
    path.getParentDirectory().createDirectory();
    path.createSymbolicLink(new PathFragment("bar"));
    fs.readlinkThrowsIoException = true;
    SkyKey fileKey = FileStateValue.key(RootedPath.toRootedPath(pkgRoot, new PathFragment("foo")));
    EvaluationResult<SkyValue> result = driver.evaluate(ImmutableList.of(fileKey), false, SkyframeExecutor.DEFAULT_THREAD_COUNT, NullEventHandler.INSTANCE);
    assertTrue(result.hasError());
    fs.readlinkThrowsIoException = false;
    FilesystemValueChecker checker = new FilesystemValueChecker(null, null);
    Diff diff = getDirtyFilesystemKeys(evaluator, checker);
    assertThat(diff.changedKeysWithoutNewValues()).isEmpty();
    assertThat(diff.changedKeysWithNewValues()).isEmpty();
}
Also used : RootedPath(com.google.devtools.build.lib.vfs.RootedPath) Path(com.google.devtools.build.lib.vfs.Path) SkyKey(com.google.devtools.build.skyframe.SkyKey) SkyValue(com.google.devtools.build.skyframe.SkyValue) Diff(com.google.devtools.build.skyframe.Differencer.Diff) PathFragment(com.google.devtools.build.lib.vfs.PathFragment) Test(org.junit.Test)

Example 2 with Diff

use of com.google.devtools.build.skyframe.Differencer.Diff in project bazel by bazelbuild.

the class InMemoryMemoizingEvaluator method evaluate.

@Override
public <T extends SkyValue> EvaluationResult<T> evaluate(Iterable<SkyKey> roots, Version version, boolean keepGoing, int numThreads, ExtendedEventHandler eventHandler) throws InterruptedException {
    // NOTE: Performance critical code. See bug "Null build performance parity".
    IntVersion intVersion = (IntVersion) version;
    Preconditions.checkState((lastGraphVersion == null && intVersion.getVal() == 0) || version.equals(lastGraphVersion.next()), "InMemoryGraph supports only monotonically increasing Integer versions: %s %s", lastGraphVersion, version);
    setAndCheckEvaluateState(true, roots);
    try {
        // Mark for removal any inflight nodes from the previous evaluation.
        valuesToDelete.addAll(progressReceiver.getAndClearInflightKeys());
        // The RecordingDifferencer implementation is not quite working as it should be at this point.
        // It clears the internal data structures after getDiff is called and will not return
        // diffs for historical versions. This makes the following code sensitive to interrupts.
        // Ideally we would simply not update lastGraphVersion if an interrupt occurs.
        Diff diff = differencer.getDiff(new DelegatingWalkableGraph(graph), lastGraphVersion, version);
        valuesToInject.putAll(diff.changedKeysWithNewValues());
        invalidate(diff.changedKeysWithoutNewValues());
        pruneInjectedValues(valuesToInject);
        invalidate(valuesToInject.keySet());
        performInvalidation();
        injectValues(intVersion);
        ParallelEvaluator evaluator = new ParallelEvaluator(graph, intVersion, skyFunctions, eventHandler, emittedEventState, DEFAULT_STORED_EVENT_FILTER, keepGoing, numThreads, progressReceiver);
        EvaluationResult<T> result = evaluator.eval(roots);
        return EvaluationResult.<T>builder().mergeFrom(result).setWalkableGraph(new DelegatingWalkableGraph(graph)).build();
    } finally {
        lastGraphVersion = intVersion;
        setAndCheckEvaluateState(false, roots);
    }
}
Also used : Diff(com.google.devtools.build.skyframe.Differencer.Diff)

Example 3 with Diff

use of com.google.devtools.build.skyframe.Differencer.Diff in project bazel by bazelbuild.

the class FilesystemValueCheckerTest method testFilesInCycleNotConsideredDirty.

@Test
public void testFilesInCycleNotConsideredDirty() throws Exception {
    Path path1 = pkgRoot.getRelative("foo1");
    Path path2 = pkgRoot.getRelative("foo2");
    Path path3 = pkgRoot.getRelative("foo3");
    FileSystemUtils.ensureSymbolicLink(path1, path2);
    FileSystemUtils.ensureSymbolicLink(path2, path3);
    FileSystemUtils.ensureSymbolicLink(path3, path1);
    SkyKey fileKey1 = FileValue.key(RootedPath.toRootedPath(pkgRoot, path1));
    EvaluationResult<SkyValue> result = driver.evaluate(ImmutableList.of(fileKey1), false, SkyframeExecutor.DEFAULT_THREAD_COUNT, NullEventHandler.INSTANCE);
    assertTrue(result.hasError());
    FilesystemValueChecker checker = new FilesystemValueChecker(null, null);
    Diff diff = getDirtyFilesystemKeys(evaluator, checker);
    assertThat(diff.changedKeysWithoutNewValues()).isEmpty();
    assertThat(diff.changedKeysWithNewValues()).isEmpty();
}
Also used : RootedPath(com.google.devtools.build.lib.vfs.RootedPath) Path(com.google.devtools.build.lib.vfs.Path) SkyKey(com.google.devtools.build.skyframe.SkyKey) SkyValue(com.google.devtools.build.skyframe.SkyValue) Diff(com.google.devtools.build.skyframe.Differencer.Diff) Test(org.junit.Test)

Aggregations

Diff (com.google.devtools.build.skyframe.Differencer.Diff)3 Path (com.google.devtools.build.lib.vfs.Path)2 RootedPath (com.google.devtools.build.lib.vfs.RootedPath)2 SkyKey (com.google.devtools.build.skyframe.SkyKey)2 SkyValue (com.google.devtools.build.skyframe.SkyValue)2 Test (org.junit.Test)2 PathFragment (com.google.devtools.build.lib.vfs.PathFragment)1