aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib
diff options
context:
space:
mode:
authorGravatar Philipp Wollermann <philwo@google.com>2016-03-03 22:21:11 +0000
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2016-03-04 12:16:48 +0000
commite873ec880e198e7e8f403743e04de4c64aa5dffe (patch)
treea195dd974f8a6d6838166d07bb090020fc6ada15 /src/main/java/com/google/devtools/build/lib
parent191d9804047fe2d19c6ca561b6f8de6ccbdc93fb (diff)
Include the file count in ChangedFilesMessage.
-- MOS_MIGRATED_REVID=116292374
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib')
-rw-r--r--src/main/java/com/google/devtools/build/lib/actions/ChangedFilesMessage.java19
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/SkyframeIncrementalBuildMonitor.java12
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));
}
}