Skip to content

Commit

Permalink
Apply the event-based result collecting approach to regular blaze.
Browse files Browse the repository at this point in the history
This change is guarded behind
--experimental_use_event_based_build_completion_status. At the moment, we unconditionally carry out both modes of collection and only choose the result of the event-based method if the flag is flipped to "true".

PiperOrigin-RevId: 444269565
  • Loading branch information
joeleba authored and Copybara-Service committed Apr 25, 2022
1 parent e060edf commit 4e6153e
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,17 @@ public ThreadConverter() {
@Nullable
public PathFragment aqueryDumpAfterBuildOutputFile;

@Option(
name = "experimental_use_event_based_build_completion_status",
defaultValue = "false",
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
metadataTags = OptionMetadataTag.EXPERIMENTAL,
effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS, OptionEffectTag.EXECUTION},
help =
"If this flag is set, use the event bus to keep track of whether a top-level target or"
+ " its aspect is analyzed/built.")
public boolean useEventBasedBuildCompletionStatus;

/**
* Converter for jobs: Takes keyword ({@value #FLAG_SYNTAX}). Values must be between 1 and
* MAX_JOBS.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,8 @@ public void buildTargets(BuildRequest request, BuildResult result, TargetValidat
analysisResult,
result,
analysisResult.getPackageRoots(),
request.getTopLevelArtifactContext());
request.getTopLevelArtifactContext(),
request.getBuildOptions().useEventBasedBuildCompletionStatus);
} else {
env.getReporter().post(new NoExecutionEvent());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public final class ExecutionProgressReceiver
*/
ExecutionProgressReceiver(
Set<ConfiguredTargetKey> builtTargets, Set<AspectKey> builtAspects, int exclusiveTestsCount) {
// TODO(b/227138583) Remove these.
this.builtTargets = Collections.synchronizedSet(builtTargets);
this.builtAspects = Collections.synchronizedSet(builtAspects);
this.exclusiveTestsCount = exclusiveTestsCount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,8 @@ void executeBuild(
AnalysisResult analysisResult,
BuildResult buildResult,
PackageRoots packageRoots,
TopLevelArtifactContext topLevelArtifactContext)
TopLevelArtifactContext topLevelArtifactContext,
boolean useEventBasedBuildCompletionStatus)
throws BuildFailedException, InterruptedException, TestExecException, AbruptExitException {
Stopwatch timer = Stopwatch.createStarted();
prepare(packageRoots, analysisResult.getNonSymlinkedDirectoriesUnderExecRoot());
Expand Down Expand Up @@ -436,6 +437,7 @@ void executeBuild(
installExplanationHandler(
request.getBuildOptions().explanationPath, request.getOptionsDescription());

// TODO(b/227138583): Remove these.
Set<ConfiguredTargetKey> builtTargets = new HashSet<>();
Set<AspectKey> builtAspects = new HashSet<>();

Expand Down Expand Up @@ -532,6 +534,11 @@ void executeBuild(
saveActionCache(actionCache);
}

if (useEventBasedBuildCompletionStatus) {
builtTargets = env.getBuildResultListener().getBuiltTargets();
builtAspects = env.getBuildResultListener().getBuiltAspects();
}

try (SilentCloseable c = Profiler.instance().profile("Show results")) {
buildResult.setSuccessfulTargets(
determineSuccessfulTargets(configuredTargets, builtTargets));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,6 @@ public void addResponseExtensions(Iterable<Any> extensions) {
responseExtensions.addAll(extensions);
}

@Nullable
public BuildResultListener getBuildResultListener() {
return buildResultListener;
}
Expand Down

0 comments on commit 4e6153e

Please sign in to comment.