diff options
author | 2017-08-03 03:27:55 +0200 | |
---|---|---|
committer | 2017-08-03 12:10:06 +0200 | |
commit | 781b23a6e161d2d32e0a1d8fd699a7a0bda113a1 (patch) | |
tree | 723c807acacadfbeeb381bd58ee93d5a3abf5771 /src/main/java/com/google/devtools/build/lib/rules/python/PythonUtils.java | |
parent | a08bb897569f6d8fd5e0459b67d26c3e9ac69a82 (diff) |
Compute progress message lazily in spawn action.
Consumers using spawn action builder now have access to handy overloads that behind the scene do a lazy String.format. In 95% of cases progress messages are expressible as 0, 1, or 2 argument String.formats.
This saves memory because the format string is constant and shared between all actions, and the captured subjects are usually live on the heap anyway (eg. labels).
Skylark still computes its progress messages eagerly. If we want similar savings there I'd have to follow up with a Skylark proposal.
PiperOrigin-RevId: 164068816
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/python/PythonUtils.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/python/PythonUtils.java | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/python/PythonUtils.java b/src/main/java/com/google/devtools/build/lib/rules/python/PythonUtils.java index ebe030fa41..524ced33d3 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/python/PythonUtils.java +++ b/src/main/java/com/google/devtools/build/lib/rules/python/PythonUtils.java @@ -23,7 +23,6 @@ import com.google.devtools.build.lib.analysis.Runfiles; import com.google.devtools.build.lib.analysis.actions.SpawnAction; import com.google.devtools.build.lib.util.FileType; import com.google.devtools.build.lib.vfs.PathFragment; - import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -120,14 +119,15 @@ public final class PythonUtils { argv.add("--write-unchanged-files"); argv.add(input.getExecPathString()); - ruleContext.registerAction(new SpawnAction.Builder() - .addInput(input) - .addOutput(output) - .setExecutable(py2to3converter) - .addArguments(argv) - .setProgressMessage("Converting to Python 3: " + input.prettyPrint()) - .setMnemonic("2to3") - .build(ruleContext)); + ruleContext.registerAction( + new SpawnAction.Builder() + .addInput(input) + .addOutput(output) + .setExecutable(py2to3converter) + .addArguments(argv) + .setProgressMessage("Converting to Python 3: %s", input.prettyPrint()) + .setMnemonic("2to3") + .build(ruleContext)); return output; } } |