From d2eff4ea252b8da2f1e0fe2e12e07d83a53cdf9d Mon Sep 17 00:00:00 2001 From: Mark Schaller Date: Tue, 24 Nov 2015 01:20:17 +0000 Subject: Avoid extra rdeps copy when finishing node Reduces garbage and wasted work -- MOS_MIGRATED_REVID=108566164 --- src/main/java/com/google/devtools/build/skyframe/BuildingState.java | 6 ++++++ .../java/com/google/devtools/build/skyframe/InMemoryNodeEntry.java | 4 ++-- .../java/com/google/devtools/build/skyframe/ReverseDepsUtil.java | 2 ++ .../com/google/devtools/build/skyframe/ReverseDepsUtilImpl.java | 5 +++++ 4 files changed, 15 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main/java/com/google/devtools/build/skyframe/BuildingState.java b/src/main/java/com/google/devtools/build/skyframe/BuildingState.java index ad16c38a88..ae38e8ce4e 100644 --- a/src/main/java/com/google/devtools/build/skyframe/BuildingState.java +++ b/src/main/java/com/google/devtools/build/skyframe/BuildingState.java @@ -153,6 +153,12 @@ public class BuildingState { List getDataToConsolidate(BuildingState container) { return container.reverseDepsDataToConsolidate; } + + @Override + public void consolidateReverseDeps(BuildingState container) { + // #consolidateReverseDeps is only supported for node entries, not building states. + throw new UnsupportedOperationException(); + } }; // Below are fields that are used for dirty nodes. 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 261c836344..95d23bd702 100644 --- a/src/main/java/com/google/devtools/build/skyframe/InMemoryNodeEntry.java +++ b/src/main/java/com/google/devtools/build/skyframe/InMemoryNodeEntry.java @@ -221,8 +221,8 @@ public class InMemoryNodeEntry implements NodeEntry { // Get reverse deps that need to be signaled. ImmutableSet reverseDepsToSignal = buildingState.getReverseDepsToSignal(); getReverseDepsUtil().addReverseDeps(this, reverseDepsToSignal); - // Force consistency check. - getReverseDepsUtil().getReverseDeps(this); + // Force consistency check and consolidate rdeps changes. + getReverseDepsUtil().consolidateReverseDeps(this); this.directDeps = buildingState.getFinishedDirectDeps().compress(); markDone(); diff --git a/src/main/java/com/google/devtools/build/skyframe/ReverseDepsUtil.java b/src/main/java/com/google/devtools/build/skyframe/ReverseDepsUtil.java index 219758b30d..52ad31229c 100644 --- a/src/main/java/com/google/devtools/build/skyframe/ReverseDepsUtil.java +++ b/src/main/java/com/google/devtools/build/skyframe/ReverseDepsUtil.java @@ -39,6 +39,8 @@ public interface ReverseDepsUtil { void removeReverseDep(T container, SkyKey reverseDep); + void consolidateReverseDeps(T container); + ImmutableSet getReverseDeps(T container); String toString(T container); diff --git a/src/main/java/com/google/devtools/build/skyframe/ReverseDepsUtilImpl.java b/src/main/java/com/google/devtools/build/skyframe/ReverseDepsUtilImpl.java index 11af1005a7..7eda036ee0 100644 --- a/src/main/java/com/google/devtools/build/skyframe/ReverseDepsUtilImpl.java +++ b/src/main/java/com/google/devtools/build/skyframe/ReverseDepsUtilImpl.java @@ -283,6 +283,11 @@ public abstract class ReverseDepsUtilImpl implements ReverseDepsUtil { } } + @Override + public void consolidateReverseDeps(T container) { + consolidateData(container); + } + private void consolidateData(T container) { List dataToConsolidate = getDataToConsolidate(container); if (dataToConsolidate == null) { -- cgit v1.2.3