diff options
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/actions/ChangedFilesMessage.java | 19 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/skyframe/SkyframeIncrementalBuildMonitor.java | 12 |
2 files changed, 25 insertions, 6 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/actions/ChangedFilesMessage.java b/src/main/java/com/google/devtools/build/lib/actions/ChangedFilesMessage.java index f2d0ea8f3c..09b439c779 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/ChangedFilesMessage.java +++ b/src/main/java/com/google/devtools/build/lib/actions/ChangedFilesMessage.java @@ -20,17 +20,32 @@ import java.util.Set; /** * A message sent conveying a set of changed files. This is sent over the event bus if a build is - * discovered to have few changed files. If many files have changed, it will not be sent at all. + * discovered to have changed files. If many files have changed, the set of changed files will + * be empty, but {@link #getChangedFileCount} will still return the correct number. */ public class ChangedFilesMessage { private final Set<PathFragment> changedFiles; + private final int changedFileCount; - public ChangedFilesMessage(Set<PathFragment> changedFiles) { + public ChangedFilesMessage(Set<PathFragment> changedFiles, int changedFileCount) { this.changedFiles = ImmutableSet.copyOf(changedFiles); + this.changedFileCount = changedFileCount; } + /** + * Returns a set with one PathFragment for each file that was changed since the last build, or + * an empty set if the set is unknown or would be too big. + */ public Set<PathFragment> getChangedFiles() { return changedFiles; } + + /** + * Returns the number of changed files. This will always be the correct number of files, even when + * {@link #getChangedFiles} might return an empty set, because the actual set would be too big. + */ + public int getChangedFileCount() { + return changedFileCount; + } } diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeIncrementalBuildMonitor.java b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeIncrementalBuildMonitor.java index a719bec42e..bb277160c1 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeIncrementalBuildMonitor.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeIncrementalBuildMonitor.java @@ -13,6 +13,7 @@ // limitations under the License. package com.google.devtools.build.lib.skyframe; +import com.google.common.collect.ImmutableSet; import com.google.common.eventbus.EventBus; import com.google.devtools.build.lib.actions.ChangedFilesMessage; import com.google.devtools.build.lib.concurrent.ThreadSafety; @@ -30,9 +31,11 @@ import java.util.Set; */ @ThreadSafety.ThreadCompatible class SkyframeIncrementalBuildMonitor { - private Set<PathFragment> files = new HashSet<>(); private static final int MAX_FILES = 100; + private Set<PathFragment> files = new HashSet<>(); + private int fileCount; + public void accrue(Iterable<SkyKey> invalidatedValues) { for (SkyKey skyKey : invalidatedValues) { if (skyKey.functionName().equals(SkyFunctions.FILE_STATE)) { @@ -49,11 +52,12 @@ class SkyframeIncrementalBuildMonitor { files = null; } } + + fileCount++; } public void alertListeners(EventBus eventBus) { - if (files != null) { - eventBus.post(new ChangedFilesMessage(files)); - } + Set<PathFragment> changedFiles = (files != null) ? files : ImmutableSet.<PathFragment>of(); + eventBus.post(new ChangedFilesMessage(changedFiles, fileCount)); } } |