Skip to content
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

enable iterations for microbenchmarks #4188

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ environment:
environment_variables: {}
default_max_seconds: 300
framework_version: net8.0
# uncomment once we implement iteration mechanism in the ASP.NET command
# iterations: 1
benchmark_settings:
benchmark_file: C:\InfraRuns\RunNew_All\Suites\ASPNETBenchmarks\ASPNetBenchmarks.csv
# To take a dump: --application.options.dumpType full --application.options.dumpOutput <filename>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ microbenchmark_configurations:
bdn_arguments: --warmupCount 1 --iterationCount 20 --allStats --outliers DontRemove --keepFiles
environment:
default_max_seconds: 3000
iterations: 1
output:
cpu_columns:
additional_report_metrics:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ microbenchmark_configurations:
bdn_arguments: --warmupCount 1 --iterationCount 20 --allStats --outliers DontRemove --keepFiles
environment:
default_max_seconds: 3000
iterations: 1
output:
cpu_columns:
additional_report_metrics:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public class Environment
public Dictionary<string, string> environment_variables { get; set; } = new();
public uint default_max_seconds { get; set; } = 300;
public string framework_version { get; set; } = "net8.0";
// uncomment once we implement iteration mechanism in the ASP.NET command
// public uint Iterations { get; set; } = 1;
}

public class BenchmarkSettings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public sealed class Run : RunBase
public class Environment
{
public uint default_max_seconds { get; set; } = 300;
public uint Iterations { get; set; } = 1;
Copy link
Member

Choose a reason for hiding this comment

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

I don't see a corresponding implementation of the iteration mechanism in the ASP.NET command. Should we get rid of this until we have one?

}

public sealed class MicrobenchmarkConfigurations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ public static MicrobenchmarkOutputResults RunMicrobenchmarks(MicrobenchmarkConfi

foreach (var run in configuration.Runs)
{
AnsiConsole.Markup($"[bold green] ({DateTime.Now}) Running Microbechmarks: {configuration.Name} - {run.Key} {benchmark} [/]\n");
string runPath = Path.Combine(configuration.Output.Path, run.Key);

// Create the run path directory.
Expand All @@ -150,45 +149,52 @@ public static MicrobenchmarkOutputResults RunMicrobenchmarks(MicrobenchmarkConfi
(string, string) fileNameAndCommand = MicrobenchmarkCommandBuilder.Build(configuration, run, benchmark, invocationCountFromBaseline);
run.Value.Name = run.Key;

// Run The BDN process with the trace collector.
using (Process bdnProcess = new())
for (int iterationIdx = 0; iterationIdx < configuration.Environment.Iterations; iterationIdx++)
{
bdnProcess.StartInfo.FileName = fileNameAndCommand.Item1;
bdnProcess.StartInfo.Arguments = fileNameAndCommand.Item2;
bdnProcess.StartInfo.UseShellExecute = false;
bdnProcess.StartInfo.RedirectStandardError = true;
bdnProcess.StartInfo.RedirectStandardOutput = true;
bdnProcess.StartInfo.CreateNoWindow = true;

StringBuilder consoleOutput = new();
StringBuilder consoleError = new();

bdnProcess.OutputDataReceived += (s, e) =>
// Run The BDN process with the trace collector.
using (Process bdnProcess = new())
{
consoleOutput.AppendLine(e.Data);

};

bdnProcess.ErrorDataReceived += (s, e) =>
{
consoleError.AppendLine(e.Data);
};

using (TraceCollector traceCollector = new TraceCollector(benchmarkCleanedName, collectType, runPath))
{
bdnProcess.Start();
bdnProcess.BeginOutputReadLine();
bdnProcess.BeginErrorReadLine();
bdnProcess.WaitForExit((int)configuration.Environment.default_max_seconds * 1000);
bdnProcess.StartInfo.FileName = fileNameAndCommand.Item1;
bdnProcess.StartInfo.Arguments = fileNameAndCommand.Item2;
bdnProcess.StartInfo.UseShellExecute = false;
bdnProcess.StartInfo.RedirectStandardError = true;
bdnProcess.StartInfo.RedirectStandardOutput = true;
bdnProcess.StartInfo.CreateNoWindow = true;

AnsiConsole.Markup($"[bold green] ({DateTime.Now}) Running Microbechmarks: {configuration.Name} - {run.Key} {benchmark} - Iteration: {iterationIdx} [/]\n");

StringBuilder consoleOutput = new();
StringBuilder consoleError = new();

bdnProcess.OutputDataReceived += (s, e) =>
{
consoleOutput.AppendLine(e.Data);

};

bdnProcess.ErrorDataReceived += (s, e) =>
{
consoleError.AppendLine(e.Data);
};

string key = $"{run.Key}.{benchmarkCleanedName}.{iterationIdx}";
string traceName = $"{run.Key}.{benchmarkCleanedName}.{iterationIdx}";
using (TraceCollector traceCollector = new TraceCollector(traceName, collectType, runPath))
{
bdnProcess.Start();
bdnProcess.BeginOutputReadLine();
bdnProcess.BeginErrorReadLine();
bdnProcess.WaitForExit((int)configuration.Environment.default_max_seconds * 1000);
}

ProcessExecutionDetails details = new(key: key,
commandlineArgs: $"{fileNameAndCommand.Item1} {fileNameAndCommand.Item2}",
environmentVariables: run.Value.environment_variables,
standardError: consoleError.ToString(),
standardOut: consoleOutput.ToString(),
exitCode: bdnProcess.ExitCode);
executionDetails[key] = details;
}

ProcessExecutionDetails details = new(key: $"{run.Key}_{benchmark}",
commandlineArgs: $"{fileNameAndCommand.Item1} {fileNameAndCommand.Item2}",
environmentVariables: run.Value.environment_variables,
standardError: consoleError.ToString(),
standardOut: consoleOutput.ToString(),
exitCode: bdnProcess.ExitCode);
executionDetails[$"{run.Key}_{benchmark}"] = details;
}
}
}
Expand Down