Skip to content

Commit 1a6ffe6

Browse files
YuanHao97copybara-github
authored andcommitted
Add a flag to disable execution log sorting.
This may improve performance when the execution log gets very large. The default is still to sort, so this is a backwards-compatible change. Closes bazelbuild#17354. Closes bazelbuild#17111. PiperOrigin-RevId: 509822315 Change-Id: If948ec4a933389b6f8405985813dd76c549c445c
1 parent 72f0045 commit 1a6ffe6

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

src/main/java/com/google/devtools/build/lib/bazel/BUILD

+1
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ java_library(
123123
"//src/main/java/com/google/devtools/build/lib/util/io",
124124
"//src/main/java/com/google/devtools/build/lib/vfs",
125125
"//src/main/protobuf:failure_details_java_proto",
126+
"//src/main/protobuf:spawn_java_proto",
126127
],
127128
)
128129

src/main/java/com/google/devtools/build/lib/bazel/SpawnLogModule.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.google.devtools.build.lib.exec.ExecutionOptions;
2020
import com.google.devtools.build.lib.exec.ExecutorBuilder;
2121
import com.google.devtools.build.lib.exec.ModuleActionContextRegistry;
22+
import com.google.devtools.build.lib.exec.Protos.SpawnExec;
2223
import com.google.devtools.build.lib.exec.SpawnLogContext;
2324
import com.google.devtools.build.lib.remote.options.RemoteOptions;
2425
import com.google.devtools.build.lib.runtime.BlazeModule;
@@ -162,7 +163,14 @@ public void afterCommand() throws AbruptExitException {
162163
spawnLogContext.close();
163164
if (!outputStreams.isEmpty()) {
164165
InputStream in = rawOutput.getInputStream();
165-
StableSort.stableSort(in, outputStreams);
166+
if (spawnLogContext.shouldSort()) {
167+
StableSort.stableSort(in, outputStreams);
168+
} else {
169+
while (in.available() > 0) {
170+
SpawnExec ex = SpawnExec.parseDelimitedFrom(in);
171+
outputStreams.write(ex);
172+
}
173+
}
166174
outputStreams.close();
167175
}
168176
done = true;

src/main/java/com/google/devtools/build/lib/exec/ExecutionOptions.java

+11
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,17 @@ public boolean usingLocalTestJobs() {
472472
+ " --subcommands (for displaying subcommands in terminal output).")
473473
public PathFragment executionLogJsonFile;
474474

475+
@Option(
476+
name = "execution_log_sort",
477+
defaultValue = "true",
478+
documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
479+
effectTags = {OptionEffectTag.UNKNOWN},
480+
help =
481+
"Whether to sort the execution log. Set to false to improve memory"
482+
+ " performance, at the cost of producing the log in nondeterministic"
483+
+ " order.")
484+
public boolean executionLogSort;
485+
475486
@Option(
476487
name = "experimental_split_xml_generation",
477488
defaultValue = "true",

src/main/java/com/google/devtools/build/lib/exec/SpawnLogContext.java

+4
Original file line numberDiff line numberDiff line change
@@ -332,4 +332,8 @@ private Digest computeDigest(
332332
.setSizeBytes(fileSize)
333333
.build();
334334
}
335+
336+
public boolean shouldSort() {
337+
return executionOptions.executionLogSort;
338+
}
335339
}

0 commit comments

Comments
 (0)