aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java
diff options
context:
space:
mode:
authorGravatar shahan <shahan@google.com>2018-05-11 09:46:54 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-05-11 09:48:45 -0700
commitcfc64a3910ed7c144763f4156a9b4979c5f15d96 (patch)
tree37e81201d4fe835e2483893008978fbb17d93d96 /src/main/java
parent91b867f6b1b5c417172efe1fa278282d14500922 (diff)
Records profiling information for ActionFS staging and updates.
PiperOrigin-RevId: 196266567
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/profiler/ProfilerTask.java2
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/ActionFileSystem.java84
2 files changed, 50 insertions, 36 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/profiler/ProfilerTask.java b/src/main/java/com/google/devtools/build/lib/profiler/ProfilerTask.java
index 10560db143..804a154721 100644
--- a/src/main/java/com/google/devtools/build/lib/profiler/ProfilerTask.java
+++ b/src/main/java/com/google/devtools/build/lib/profiler/ProfilerTask.java
@@ -89,6 +89,8 @@ public enum ProfilerTask {
SKYLARK_USER_FN("Skylark user function call", -1, 0xCC0033, 0),
SKYLARK_BUILTIN_FN("Skylark builtin function call", -1, 0x990033, 0),
SKYLARK_USER_COMPILED_FN("Skylark compiled user function call", -1, 0xCC0033, 0),
+ ACTION_FS_STAGING("Staging per-action file system", -1, 0x000000, 0),
+ ACTION_FS_UPDATE("Updating per-action file system", -1, 0x000000, 0),
UNKNOWN("Unknown event", -1, 0x339966, 0);
// Size of the ProfilerTask value space.
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ActionFileSystem.java b/src/main/java/com/google/devtools/build/lib/skyframe/ActionFileSystem.java
index 62e9761abd..6ebc0cbcf2 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/ActionFileSystem.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/ActionFileSystem.java
@@ -23,6 +23,8 @@ import com.google.devtools.build.lib.actions.ActionInput;
import com.google.devtools.build.lib.actions.ActionInputFileCache;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.actions.FileStateType;
+import com.google.devtools.build.lib.profiler.Profiler;
+import com.google.devtools.build.lib.profiler.ProfilerTask;
import com.google.devtools.build.lib.vfs.AbstractFileSystem;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
@@ -89,33 +91,38 @@ final class ActionFileSystem extends AbstractFileSystem implements ActionInputFi
Map<Artifact, FileArtifactValue> inputData,
Iterable<Artifact> allowedInputs,
Iterable<Artifact> outputArtifacts) {
- roots.add(computeExecRoot(outputArtifacts));
-
- // TODO(shahan): Underestimates because this doesn't account for discovered inputs. Improve
- // this estimate using data.
- this.reverseMap = new ConcurrentHashMap<>(inputData.size());
-
- HashMap<PathFragment, ArtifactAndMetadata> inputs = new HashMap<>();
- for (Map.Entry<Artifact, FileArtifactValue> entry : inputData.entrySet()) {
- Artifact input = entry.getKey();
- updateRootsIfSource(input);
- inputs.put(input.getExecPath(), new SimpleArtifactAndMetadata(input, entry.getValue()));
- updateReverseMapIfDigestExists(entry.getValue(), entry.getKey());
- }
- for (Artifact input : allowedInputs) {
- PathFragment execPath = input.getExecPath();
- inputs.computeIfAbsent(execPath, unused -> new OptionalInputArtifactAndMetadata(input));
- updateRootsIfSource(input);
- }
- this.inputs = inputs;
+ try {
+ Profiler.instance().startTask(ProfilerTask.ACTION_FS_STAGING, "staging");
+ roots.add(computeExecRoot(outputArtifacts));
+
+ // TODO(shahan): Underestimates because this doesn't account for discovered inputs. Improve
+ // this estimate using data.
+ this.reverseMap = new ConcurrentHashMap<>(inputData.size());
+
+ HashMap<PathFragment, ArtifactAndMetadata> inputs = new HashMap<>();
+ for (Map.Entry<Artifact, FileArtifactValue> entry : inputData.entrySet()) {
+ Artifact input = entry.getKey();
+ updateRootsIfSource(input);
+ inputs.put(input.getExecPath(), new SimpleArtifactAndMetadata(input, entry.getValue()));
+ updateReverseMapIfDigestExists(entry.getValue(), entry.getKey());
+ }
+ for (Artifact input : allowedInputs) {
+ PathFragment execPath = input.getExecPath();
+ inputs.computeIfAbsent(execPath, unused -> new OptionalInputArtifactAndMetadata(input));
+ updateRootsIfSource(input);
+ }
+ this.inputs = inputs;
- validateRoots();
+ validateRoots();
- this.outputs =
- Streams.stream(outputArtifacts)
- .collect(
- ImmutableMap.toImmutableMap(
- a -> a.getExecPath(), a -> new ArtifactAndMutableMetadata(a)));
+ this.outputs =
+ Streams.stream(outputArtifacts)
+ .collect(
+ ImmutableMap.toImmutableMap(
+ a -> a.getExecPath(), a -> new ArtifactAndMutableMetadata(a)));
+ } finally {
+ Profiler.instance().completeTask(ProfilerTask.ACTION_FS_STAGING);
+ }
}
/**
@@ -132,18 +139,23 @@ final class ActionFileSystem extends AbstractFileSystem implements ActionInputFi
/** Input discovery changes the values of the input data map so it must be updated accordingly. */
public void updateInputData(Map<Artifact, FileArtifactValue> inputData) {
- boolean foundNewRoots = false;
- for (Map.Entry<Artifact, FileArtifactValue> entry : inputData.entrySet()) {
- ArtifactAndMetadata current = inputs.get(entry.getKey().getExecPath());
- if (current == null || isUnsetOptional(current)) {
- Artifact input = entry.getKey();
- inputs.put(input.getExecPath(), new SimpleArtifactAndMetadata(input, entry.getValue()));
- foundNewRoots = updateRootsIfSource(entry.getKey()) || foundNewRoots;
- updateReverseMapIfDigestExists(entry.getValue(), entry.getKey());
+ try {
+ Profiler.instance().startTask(ProfilerTask.ACTION_FS_UPDATE, "update");
+ boolean foundNewRoots = false;
+ for (Map.Entry<Artifact, FileArtifactValue> entry : inputData.entrySet()) {
+ ArtifactAndMetadata current = inputs.get(entry.getKey().getExecPath());
+ if (current == null || isUnsetOptional(current)) {
+ Artifact input = entry.getKey();
+ inputs.put(input.getExecPath(), new SimpleArtifactAndMetadata(input, entry.getValue()));
+ foundNewRoots = updateRootsIfSource(entry.getKey()) || foundNewRoots;
+ updateReverseMapIfDigestExists(entry.getValue(), entry.getKey());
+ }
}
- }
- if (foundNewRoots) {
- validateRoots();
+ if (foundNewRoots) {
+ validateRoots();
+ }
+ } finally {
+ Profiler.instance().completeTask(ProfilerTask.ACTION_FS_UPDATE);
}
}