aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkActionFactory.java
diff options
context:
space:
mode:
authorGravatar tomlu <tomlu@google.com>2018-02-21 21:43:24 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2018-02-21 21:45:19 -0800
commit0cf94e91ea8d3fbab9c12f92e19e8fa9ad9e8a65 (patch)
treee63bfed7bcca70cf1d81d12e93984f95ca26040d /src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkActionFactory.java
parentdeb99ccfb4e6b236c21e6d425281870aa598804a (diff)
Do not expand depset twice and store expanded in ctx.actions.run inputs.
Previously, when inputs is a depset, we'd: * Expand it to a collection, then * Expand it again and add it as a flat list to the input builder This would be square on both performance and analysis time memory. Note that we _still_ expand the depset once to try to see if any input is a tool. This will have to be fixed in a future CL. RELNOTES: None PiperOrigin-RevId: 186566243
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkActionFactory.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkActionFactory.java7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkActionFactory.java b/src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkActionFactory.java
index 4ba8102860..d991f493f4 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkActionFactory.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkActionFactory.java
@@ -599,7 +599,6 @@ public class SkylarkActionFactory implements SkylarkValue {
throws EvalException {
context.checkMutable("actions.run_shell");
- // TODO(bazel-team): builder still makes unnecessary copies of inputs, outputs and args.
SkylarkList argumentList = (SkylarkList) arguments;
SpawnAction.Builder builder = new SpawnAction.Builder();
buildCommandLine(builder, argumentList);
@@ -705,14 +704,14 @@ public class SkylarkActionFactory implements SkylarkValue {
Object inputManifestsUnchecked,
SpawnAction.Builder builder)
throws EvalException {
- // TODO(bazel-team): builder still makes unnecessary copies of inputs, outputs and args.
Iterable<Artifact> inputArtifacts;
if (inputs instanceof SkylarkList) {
inputArtifacts = ((SkylarkList) inputs).getContents(Artifact.class, "inputs");
builder.addInputs(inputArtifacts);
} else {
- inputArtifacts = ((SkylarkNestedSet) inputs).toCollection(Artifact.class);
- builder.addInputs(((SkylarkNestedSet) inputs).getSet(Artifact.class));
+ NestedSet<Artifact> inputSet = ((SkylarkNestedSet) inputs).getSet(Artifact.class);
+ builder.addTransitiveInputs(inputSet);
+ inputArtifacts = inputSet;
}
builder.addOutputs(outputs.getContents(Artifact.class, "outputs"));