Permalink
Browse files

workers: Use workers by default for Javac.

RELNOTES: Persistent workers are now used by default for Java compilation in Bazel, which should speed up your Java builds by ~4x. You can switch back to the old behavior via --strategy=Javac=standalone. Check out http://www.bazel.io/blog/2015/12/10/java-workers.html for more details.

--
MOS_MIGRATED_REVID=128801059
  • Loading branch information...
1 parent f9bc665 commit 490f250b27183a886cf70a5fe9e99d9428141b34 @philwo philwo committed with damienmg Jul 29, 2016
@@ -46,7 +46,6 @@
import com.google.devtools.common.options.Converters.AssignmentConverter;
import com.google.devtools.common.options.Option;
import com.google.devtools.common.options.OptionsBase;
-
import java.io.IOException;
import java.util.List;
import java.util.Map;
@@ -107,6 +106,9 @@ protected BazelActionContextConsumer(BazelExecutionOptions options) {
public ImmutableMap<String, String> getSpawnActionContexts() {
Map<String, String> contexts = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+ // Default strategies for certain mnemonics - they can be overridden by --strategy= flags.
+ contexts.put("Javac", "worker");
+
contexts.put("Genrule", options.genruleStrategy);
for (Map.Entry<String, String> strategy : options.strategy) {
@@ -396,7 +396,7 @@ EOF
expect_log "Created new Work worker (id [0-9]\+)"
- worker_log=$(egrep -o -- 'logging to .*/worker-logs/.*' "$TEST_log" | sed 's/^logging to //')
+ worker_log=$(egrep -o -- 'logging to .*/worker-logs/worker-[0-9]-Work.log' "$TEST_log" | sed 's/^logging to //')
[ -e "$worker_log" ] \
|| fail "Worker log was not found"
View
@@ -9,7 +9,7 @@ genrule(
name = "BUILD-jdk7",
srcs = [":BUILD"],
outs = ["BUILD.jdk7"],
- cmd = "sed 's/_version = \"8\"/_version = \"7\"/' $< > $@",
+ cmd = "sed -e 's/_version = \"8\"/_version = \"7\"/' -e 's/javac_supports_workers = 1/javac_supports_workers = 0/' $< > $@",
)
filegroup(
@@ -124,6 +124,7 @@ java_toolchain(
ijar = ["@bazel_tools//tools/jdk:ijar"],
javabuilder = ["//tools/jdk:JavaBuilder_deploy.jar"],
javac = ["//third_party/java/jdk/langtools:javac_jar"],
+ javac_supports_workers = 1,
jvm_opts = [
"-XX:+TieredCompilation",
"-XX:TieredStopAtLevel=1",

1 comment on commit 490f250

@jart
Member
jart commented on 490f250 Aug 3, 2016

👍 A+++++

Please sign in to comment.