Skip to content

Commit

Permalink
Internal change
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 476133368
Change-Id: I137993aaeb12ea646416315cd1d56c83074f37f7
  • Loading branch information
Googler authored and copybara-github committed Sep 22, 2022
1 parent 822e049 commit a2177dc
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public final class Bazel {
com.google.devtools.build.lib.metrics.PostGCMemoryUseRecorder.GcAfterBuildModule.class,
com.google.devtools.build.lib.packages.metrics.PackageMetricsModule.class,
com.google.devtools.build.lib.metrics.MetricsModule.class,
com.google.devtools.build.lib.runtime.ExecutionGraphDumpModule.class,
com.google.devtools.build.lib.runtime.ExecutionGraphModule.class,
BazelBuiltinCommandModule.class,
com.google.devtools.build.lib.includescanning.IncludeScanningModule.class,
// This module needs to be registered after any module submitting tasks with its {@code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@
import java.util.concurrent.atomic.AtomicLong;

/** Blaze module that writes an partial execution graph with performance data. */
public class ExecutionGraphDumpModule extends BlazeModule {
public class ExecutionGraphModule extends BlazeModule {

private static final String ACTION_DUMP_NAME = "execution_graph_dump.proto.zst";

private static final GoogleLogger logger = GoogleLogger.forEnclosingClass();

/** Options for the generated execution graph. */
public static class ExecutionGraphDumpOptions extends OptionsBase {
public static class ExecutionGraphOptions extends OptionsBase {
@Option(
name = "experimental_execution_graph_log",
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
Expand Down Expand Up @@ -128,23 +128,23 @@ public static class ExecutionGraphDumpOptions extends OptionsBase {
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
effectTags = {OptionEffectTag.UNKNOWN},
defaultValue = "false",
help = "Subscribe to ActionMiddlemanEvent in ExecutionGraphDumpModule.")
help = "Subscribe to ActionMiddlemanEvent in ExecutionGraphModule.")
public boolean logMiddlemanActions;

@Option(
name = "experimental_execution_graph_log_cached",
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
effectTags = {OptionEffectTag.UNKNOWN},
defaultValue = "true",
help = "Subscribe to CachedActionEvent in ExecutionGraphDumpModule.")
help = "Subscribe to CachedActionEvent in ExecutionGraphModule.")
public boolean logCachedActions;

@Option(
name = "experimental_execution_graph_log_missed",
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
effectTags = {OptionEffectTag.UNKNOWN},
defaultValue = "true",
help = "Subscribe to ActionCompletionEvent in ExecutionGraphDumpModule.")
help = "Subscribe to ActionCompletionEvent in ExecutionGraphModule.")
public boolean logMissedActions;
}

Expand All @@ -164,14 +164,14 @@ public DependencyInfoConverter() {

private ActionDumpWriter writer;
private CommandEnvironment env;
private ExecutionGraphDumpOptions options;
private ExecutionGraphOptions options;
private NanosToMillisSinceEpochConverter nanosToMillis =
BlazeClock.createNanosToMillisSinceEpochConverter();

@Override
public Iterable<Class<? extends OptionsBase>> getCommandOptions(Command command) {
return "build".equals(command.name())
? ImmutableList.of(ExecutionGraphDumpOptions.class)
? ImmutableList.of(ExecutionGraphOptions.class)
: ImmutableList.of();
}

Expand All @@ -181,7 +181,7 @@ void setWriter(ActionDumpWriter writer) {
}

@VisibleForTesting
void setOptions(ExecutionGraphDumpOptions options) {
void setOptions(ExecutionGraphOptions options) {
this.options = options;
}

Expand All @@ -195,10 +195,10 @@ public void beforeCommand(CommandEnvironment env) {
this.env = env;

if (env.getCommand().builds()) {
ExecutionGraphDumpOptions options =
ExecutionGraphOptions options =
Preconditions.checkNotNull(
env.getOptions().getOptions(ExecutionGraphDumpOptions.class),
"ExecutionGraphDumpOptions must be present for ExecutionGraphDumpModule");
env.getOptions().getOptions(ExecutionGraphOptions.class),
"ExecutionGraphOptions must be present for ExecutionGraphModule");
if (!options.executionGraphLogFile.isBlank()) {
env.getEventBus().register(this);
}
Expand Down Expand Up @@ -678,28 +678,28 @@ private ActionDumpWriter createActionDumpWriter(CommandEnvironment env)
OptionsParsingResult parsingResult = env.getOptions();
BuildEventProtocolOptions bepOptions =
Preconditions.checkNotNull(parsingResult.getOptions(BuildEventProtocolOptions.class));
ExecutionGraphDumpOptions executionGraphDumpOptions =
Preconditions.checkNotNull(parsingResult.getOptions(ExecutionGraphDumpOptions.class));
ExecutionGraphOptions executionGraphOptions =
Preconditions.checkNotNull(parsingResult.getOptions(ExecutionGraphOptions.class));
if (bepOptions.streamingLogFileUploads) {
return new StreamingActionDumpWriter(
env.getRuntime().getBugReporter(),
env.getOptions().getOptions(LocalExecutionOptions.class).localLockfreeOutput,
newUploader(env, bepOptions).startUpload(LocalFileType.PERFORMANCE_LOG, null),
env.getCommandId(),
executionGraphDumpOptions.depType,
executionGraphDumpOptions.queueSize);
executionGraphOptions.depType,
executionGraphOptions.queueSize);
}

Path actionGraphFile =
env.getWorkingDirectory().getRelative(executionGraphDumpOptions.executionGraphLogFile);
env.getWorkingDirectory().getRelative(executionGraphOptions.executionGraphLogFile);
try {
return new FilesystemActionDumpWriter(
env.getRuntime().getBugReporter(),
env.getOptions().getOptions(LocalExecutionOptions.class).localLockfreeOutput,
actionGraphFile,
env.getCommandId(),
executionGraphDumpOptions.depType,
executionGraphDumpOptions.queueSize);
executionGraphOptions.depType,
executionGraphOptions.queueSize);
} catch (IOException e) {
throw new ActionDumpFileCreationException(actionGraphFile, e);
}
Expand Down Expand Up @@ -747,8 +747,7 @@ private static FailureDetail makeReportUploaderNeedsPackagePathsDetail() {
private static FailureDetail makeReportWriteFailedDetail() {
return FailureDetail.newBuilder()
.setMessage("could not open action dump file for writing")
.setBuildReport(
BuildReport.newBuilder().setCode(Code.BUILD_REPORT_WRITE_FAILED))
.setBuildReport(BuildReport.newBuilder().setCode(Code.BUILD_REPORT_WRITE_FAILED))
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
import com.google.devtools.build.lib.collect.nestedset.Order;
import com.google.devtools.build.lib.exec.util.FakeOwner;
import com.google.devtools.build.lib.exec.util.SpawnBuilder;
import com.google.devtools.build.lib.runtime.ExecutionGraphDumpModule.ActionDumpWriter;
import com.google.devtools.build.lib.runtime.ExecutionGraphDumpModule.DependencyInfo;
import com.google.devtools.build.lib.runtime.ExecutionGraphModule.ActionDumpWriter;
import com.google.devtools.build.lib.runtime.ExecutionGraphModule.DependencyInfo;
import com.google.devtools.build.lib.testutil.FoundationTestCase;
import com.google.devtools.build.lib.util.OS;
import com.google.devtools.build.lib.vfs.PathFragment;
Expand All @@ -73,15 +73,15 @@
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;

/** Unit tests for {@link ExecutionGraphDumpModule}. */
/** Unit tests for {@link ExecutionGraphModule}. */
@RunWith(TestParameterInjector.class)
public class ExecutionGraphDumpModuleTest extends FoundationTestCase {
private ExecutionGraphDumpModule module;
public class ExecutionGraphModuleTest extends FoundationTestCase {
private ExecutionGraphModule module;
private ArtifactRoot artifactRoot;

@Before
public void createModule() {
module = new ExecutionGraphDumpModule();
module = new ExecutionGraphModule();
}

@Before
Expand Down Expand Up @@ -371,7 +371,7 @@ public void spawnAndAction_withSameOutputs() throws Exception {

var buffer = new ByteArrayOutputStream();
startLogging(eventBus, UUID.randomUUID(), buffer, DependencyInfo.ALL);
var options = new ExecutionGraphDumpModule.ExecutionGraphDumpOptions();
var options = new ExecutionGraphModule.ExecutionGraphOptions();
options.logMissedActions = true;
module.setOptions(options);

Expand Down Expand Up @@ -405,7 +405,7 @@ public void spawnAndAction_withDifferentOutputs() throws Exception {

var buffer = new ByteArrayOutputStream();
startLogging(eventBus, UUID.randomUUID(), buffer, DependencyInfo.ALL);
var options = new ExecutionGraphDumpModule.ExecutionGraphDumpOptions();
var options = new ExecutionGraphModule.ExecutionGraphOptions();
options.logMissedActions = true;
module.setOptions(options);
var nanosToMillis = BlazeClock.createNanosToMillisSinceEpochConverter();
Expand Down

0 comments on commit a2177dc

Please sign in to comment.