Skip to content

feat: Add option to disable parallel build #2725

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

filzrev
Copy link
Contributor

@filzrev filzrev commented Apr 27, 2025

This PR intended to fix #2721

What's changed in this PR

  1. Add DisableParallelBuild flag to ConfigOptions.
  2. Modify BenchmarkRunnerClean::Run.
    2.1. Add BuildSequential method that build project in sequentially.
    2.2. Add logics to check DisableParallelBuild option. If any of benchmarks contains DisableParallelBuild flag. Use sequential build path instead of parallel build path.

Test
I've manually confirmed that sequential build path is called when specifying WithOptions(ConfigOptions.DisableParallelBuild); on benchmark config.

{
logger.WriteLineHeader($"// ***** Building {buildPartitions.Length} exe(s): Start *****");

var buildLogger = buildPartitions.Length == 1 ? logger : NullLogger.Instance; // when we have just one partition we can print to std out
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just use logger directly since it's sequential.


return buildResults;

static string GetFormattedDifference(ClockSpan before, ClockSpan after)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull this local function out so both build functions can use it instead of copy-paste.

@timcassell
Copy link
Collaborator

@AndreyAkinshin @adamsitnik It's ok to use ConfigOptions enum for this? Or another method is preferred?

@timcassell timcassell requested a review from AndreyAkinshin May 1, 2025 23:35
@timcassell timcassell mentioned this pull request May 2, 2025
@@ -88,7 +88,11 @@ internal static Summary[] Run(BenchmarkRunInfo[] benchmarkRunInfos)

var buildPartitions = BenchmarkPartitioner.CreateForBuild(supportedBenchmarks, resolver);
eventProcessor.OnStartBuildStage(buildPartitions);
var buildResults = BuildInParallel(compositeLogger, rootArtifactsFolderPath, buildPartitions, in globalChronometer, eventProcessor);

bool useParallelBuild = !supportedBenchmarks.Any(x => x.Config.Options.IsSet(ConfigOptions.DisableParallelBuild));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be better to split the parallelizable builds from the sequential builds and run them both.

var parallelBenchmarks = supportedBenchmarks.Where(x => !x.Config.Options.IsSet(ConfigOptions.DisableParallelBuild));
var sequentialBenchmarks = supportedBenchmarks.Where(x => x.Config.Options.IsSet(ConfigOptions.DisableParallelBuild));

That will also make it easier for the validation step (#2676).

@AndreyAkinshin
Copy link
Member

It's ok to use ConfigOptions enum for this?

@timcassell it's OK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Add options to disable build in parallel.
3 participants