aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/skyframe
diff options
context:
space:
mode:
authorGravatar Julio Merino <jmmv@google.com>2016-11-01 20:58:16 +0000
committerGravatar Laszlo Csomor <laszlocsomor@google.com>2016-11-02 08:29:08 +0000
commit4d80aa7a5c75b6fd4684b7337d71974388c6e687 (patch)
treed7428b2378cdb511d32e4b0c87e40af0e5efc4cf /src/main/java/com/google/devtools/build/lib/skyframe
parent9c0fceb531a240e19f0d583025bea0e069ba1fc9 (diff)
Do not tickle TimestampGranularityMonitor for CONSTANT_METADATA artifacts.
"Constant metadata" artifacts represent real files whose changes should be ignored by the build system. However, these artifacts were triggering the timestamp granularity checks in TimestampGranularityMonitor because the fact that they were "constant metadata" was not respected. Avoid this so that their regeneration does not cause the build to unnecessarily stall. One of these artifacts is the volatile workspace status file, which is unconditionally updated on each build. Before this fix, "blaze build" would get stuck for up to a second waiting for file system timestamps to catch up. With this fix, the artifact is ignored and the wait is gone. This problem is magnified on macOS where the default HFS+ file system only has second-level granularity. (This also affects Linux, but because current Linux file systems have milli/nanosecond-level granularity, the wait imposed by TimestampGranularityMonitor is minimal and thus not generally noticeable.) -- MOS_MIGRATED_REVID=137867586
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/skyframe')
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/ActionMetadataHandler.java24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ActionMetadataHandler.java b/src/main/java/com/google/devtools/build/lib/skyframe/ActionMetadataHandler.java
index 28f676342c..971d84df61 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/ActionMetadataHandler.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/ActionMetadataHandler.java
@@ -108,6 +108,11 @@ public class ActionMetadataHandler implements MetadataHandler {
private final Set<Artifact> injectedFiles = Sets.newConcurrentHashSet();
private final ImmutableSet<Artifact> outputs;
+
+ /**
+ * The timestamp granularity monitor for this build.
+ * Use {@link #getTimestampGranularityMonitor(Artifact)} to fetch this member.
+ */
private final TimestampGranularityMonitor tsgm;
@VisibleForTesting
@@ -128,6 +133,19 @@ public class ActionMetadataHandler implements MetadataHandler {
}
}
+ /**
+ * Gets the {@link TimestampGranularityMonitor} to use for a given artifact.
+ *
+ * <p>If the artifact is of type "constant metadata", this returns null so that changes to such
+ * artifacts do not tickle the timestamp granularity monitor, delaying the build for no reason.
+ *
+ * @param artifact the artifact for which to fetch the timestamp granularity monitor
+ * @return the timestamp granularity monitor to use, which may be null
+ */
+ private TimestampGranularityMonitor getTimestampGranularityMonitor(Artifact artifact) {
+ return artifact.isConstantMetadata() ? null : tsgm;
+ }
+
private static Metadata metadataFromValue(FileArtifactValue value) throws FileNotFoundException {
if (value == FileArtifactValue.MISSING_FILE_MARKER
|| value == FileArtifactValue.OMITTED_FILE_MARKER) {
@@ -422,7 +440,8 @@ public class ActionMetadataHandler implements MetadataHandler {
// from the filesystem, this FileValue will not compare equal to another one created for the
// same file, because the other one will be missing its digest.
fileValue = fileValueFromArtifact(artifact,
- FileStatusWithDigestAdapter.adapt(statNoFollow), tsgm);
+ FileStatusWithDigestAdapter.adapt(statNoFollow),
+ getTimestampGranularityMonitor(artifact));
// Ensure the digest supplied matches the actual digest if it exists.
byte[] fileDigest = fileValue.getDigest();
if (fileDigest != null && !Arrays.equals(digest, fileDigest)) {
@@ -533,7 +552,8 @@ public class ActionMetadataHandler implements MetadataHandler {
/** Constructs a new FileValue, saves it, and checks inconsistent data. */
FileValue constructFileValue(Artifact artifact, @Nullable FileStatusWithDigest statNoFollow)
throws IOException {
- FileValue value = fileValueFromArtifact(artifact, statNoFollow, tsgm);
+ FileValue value = fileValueFromArtifact(artifact, statNoFollow,
+ getTimestampGranularityMonitor(artifact));
FileValue oldFsValue = outputArtifactData.putIfAbsent(artifact, value);
checkInconsistentData(artifact, oldFsValue, null);
return value;