Enable ability to selectively omit change pruning.
RELNOTES: None.
PiperOrigin-RevId: 219526770
diff --git a/src/main/java/com/google/devtools/build/skyframe/InMemoryNodeEntry.java b/src/main/java/com/google/devtools/build/skyframe/InMemoryNodeEntry.java
index b5627a5..7546375 100644
--- a/src/main/java/com/google/devtools/build/skyframe/InMemoryNodeEntry.java
+++ b/src/main/java/com/google/devtools/build/skyframe/InMemoryNodeEntry.java
@@ -84,11 +84,11 @@
/**
* Returns the last version this entry was evaluated at, even if it re-evaluated to the same
- * value. When a child signals this entry with the last version it was changed at in
- * {@link #signalDep}, this entry need not re-evaluate if the child's version is at most this
- * version, even if the {@link #lastChangedVersion} is less than this one.
+ * value. When a child signals this entry with the last version it was changed at in {@link
+ * #signalDep}, this entry need not re-evaluate if the child's version is at most this version,
+ * even if the {@link #lastChangedVersion} is less than this one.
*
- * @see #signalDep(Version)
+ * @see #signalDep(Version, SkyKey)
*/
protected Version lastEvaluatedVersion = MinimalVersion.INSTANCE;
@@ -298,7 +298,10 @@
assertVersionCompatibleWhenSettingValue(version, value);
this.lastEvaluatedVersion = version;
- if (isDirty() && getDirtyBuildingState().unchangedFromLastBuild(value)) {
+ if (!isEligibleForChangePruning()) {
+ this.lastChangedVersion = version;
+ this.value = value;
+ } else if (isDirty() && getDirtyBuildingState().unchangedFromLastBuild(value)) {
// If the value is the same as before, just use the old value. Note that we don't use the new
// value, because preserving == equality is even better than .equals() equality.
this.value = getDirtyBuildingState().getLastBuildValue();
@@ -325,6 +328,17 @@
return setStateFinishedAndReturnReverseDepsToSignal();
}
+ /**
+ * Returns {@code true} if this node is eligible to be change pruned when its value has not
+ * changed from the last build.
+ *
+ * <p>Implementations need not check whether the value has changed - this will only be called if
+ * the value has not changed.
+ */
+ protected boolean isEligibleForChangePruning() {
+ return true;
+ }
+
protected void assertVersionCompatibleWhenSettingValue(
Version version, SkyValue valueForDebugging) {
if (!this.lastChangedVersion.atMost(version)) {
@@ -593,7 +607,7 @@
@Override
public synchronized void markRebuilding() {
- getDirtyBuildingState().markRebuilding();
+ getDirtyBuildingState().markRebuilding(isEligibleForChangePruning());
}
@SuppressWarnings("unchecked")