diff --git a/src/main/java/com/google/devtools/build/lib/bazel/BUILD b/src/main/java/com/google/devtools/build/lib/bazel/BUILD index 1a49e15f964b6e..456dd41870a5b0 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/BUILD +++ b/src/main/java/com/google/devtools/build/lib/bazel/BUILD @@ -123,6 +123,7 @@ java_library( "//src/main/java/com/google/devtools/build/lib/util/io", "//src/main/java/com/google/devtools/build/lib/vfs", "//src/main/protobuf:failure_details_java_proto", + "//src/main/protobuf:spawn_java_proto", ], ) diff --git a/src/main/java/com/google/devtools/build/lib/bazel/SpawnLogModule.java b/src/main/java/com/google/devtools/build/lib/bazel/SpawnLogModule.java index f0ed66c41d0566..a0b16e6c5fbe3c 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/SpawnLogModule.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/SpawnLogModule.java @@ -19,6 +19,7 @@ import com.google.devtools.build.lib.exec.ExecutionOptions; import com.google.devtools.build.lib.exec.ExecutorBuilder; import com.google.devtools.build.lib.exec.ModuleActionContextRegistry; +import com.google.devtools.build.lib.exec.Protos.SpawnExec; import com.google.devtools.build.lib.exec.SpawnLogContext; import com.google.devtools.build.lib.remote.options.RemoteOptions; import com.google.devtools.build.lib.runtime.BlazeModule; @@ -162,7 +163,14 @@ public void afterCommand() throws AbruptExitException { spawnLogContext.close(); if (!outputStreams.isEmpty()) { InputStream in = rawOutput.getInputStream(); - StableSort.stableSort(in, outputStreams); + if (spawnLogContext.shouldSort()) { + StableSort.stableSort(in, outputStreams); + } else { + while (in.available() > 0) { + SpawnExec ex = SpawnExec.parseDelimitedFrom(in); + outputStreams.write(ex); + } + } outputStreams.close(); } done = true; diff --git a/src/main/java/com/google/devtools/build/lib/exec/ExecutionOptions.java b/src/main/java/com/google/devtools/build/lib/exec/ExecutionOptions.java index 9515288e95316d..aa90067e0d0dbf 100644 --- a/src/main/java/com/google/devtools/build/lib/exec/ExecutionOptions.java +++ b/src/main/java/com/google/devtools/build/lib/exec/ExecutionOptions.java @@ -472,6 +472,17 @@ public boolean usingLocalTestJobs() { + " --subcommands (for displaying subcommands in terminal output).") public PathFragment executionLogJsonFile; + @Option( + name = "execution_log_sort", + defaultValue = "true", + documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, + effectTags = {OptionEffectTag.UNKNOWN}, + help = + "Whether to sort the execution log. Set to false to improve memory" + + " performance, at the cost of producing the log in nondeterministic" + + " order.") + public boolean executionLogSort; + @Option( name = "experimental_split_xml_generation", defaultValue = "true", diff --git a/src/main/java/com/google/devtools/build/lib/exec/SpawnLogContext.java b/src/main/java/com/google/devtools/build/lib/exec/SpawnLogContext.java index b9efde8bd03ef1..186b8446900cfd 100644 --- a/src/main/java/com/google/devtools/build/lib/exec/SpawnLogContext.java +++ b/src/main/java/com/google/devtools/build/lib/exec/SpawnLogContext.java @@ -332,4 +332,8 @@ private Digest computeDigest( .setSizeBytes(fileSize) .build(); } + + public boolean shouldSort() { + return executionOptions.executionLogSort; + } }