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

Replay Binary Log Tool #72619

Merged
merged 10 commits into from
Mar 21, 2024
Merged

Replay Binary Log Tool #72619

merged 10 commits into from
Mar 21, 2024

Conversation

jaredpar
Copy link
Member

This adds a tool for replaying compilation events from binary logs directly to the compiler server. This is an effective tool for profiling the compiler server as it removes MSBuild overhead from the logs leaving just the compiler.

Further because it's integrated into our code base it makes it very easy to evaluate the efficacy of performance fixes. One simply needs to run replay with and without the changes against the same binary log and evaluate the differences in perfview.

This adds a tool for replaying compilation events from binary logs
directly to the compiler server. This is an effective tool for profiling
the compiler server as it removes MSBuild overhead from the logs leaving
just the compiler.

Further because it's integrated into our code base it makes it very easy
to evaluate the efficacy of performance fixes. One simply needs to run
`replay` with and without the changes against the same binary log and
evaluate the differences in perfview.
@jaredpar jaredpar requested review from a team as code owners March 20, 2024 17:29
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Infrastructure untriaged Issues and PRs which have not yet been triaged by a lead labels Mar 20, 2024
@jaredpar
Copy link
Member Author

@dotnet/roslyn-compiler PTAL

NuGet.config Outdated Show resolved Hide resolved
Comment on lines +10 to +19
<Compile Include="..\..\Compilers\Core\CommandLine\BuildProtocol.cs" />
<Compile Include="..\..\Compilers\Core\CommandLine\CompilerServerLogger.cs" />
<Compile Include="..\..\Compilers\Core\CommandLine\NativeMethods.cs" />
<Compile Include="..\..\Compilers\Core\Portable\CommitHashAttribute.cs" />
<Compile Include="..\..\Compilers\Core\Portable\InternalUtilities\PlatformInformation.cs" />
<Compile Include="..\..\Compilers\Core\Portable\InternalUtilities\Debug.cs" />
<Compile Include="..\..\Compilers\Core\Portable\InternalUtilities\NullableAttributes.cs" />
<Compile Include="..\..\Compilers\Shared\BuildServerConnection.cs" />
<Compile Include="..\..\Compilers\Shared\NamedPipeUtil.cs" />
<Compile Include="..\..\Compilers\Shared\RuntimeHostInfo.cs" />
Copy link
Member Author

Choose a reason for hiding this comment

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

It bothers me a bit that all of these files are needed to effectively run the client side of the build server. Considering changing this in a future PR to be a lot simpler. Essentially:

  1. Create a shared project that has all of this logic in it.
  2. Reference that shared project in MS.CA. Then vbc, csc and VBCSCompiler can just use the logic as they have IVT to MS.CA.
  3. Reference that shared project in MS.Build.Tasks.CA.csproj. It does not reference MS.CA (by very explicit design) hence needs its own copy of the source.
  4. Reference that project in MS.CA as well.

"${workspaceFolder}/scripts/vscode-build.ps1",
"-filePath",
"${file}",
"-msbuildEngine",
"dotnet"
],
"windows": {
"command": "powershell",
Copy link
Member Author

Choose a reason for hiding this comment

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

There is no need for this anymore as part of our repo setup includes installing pwsh as a local tool.

src/Tools/Replay/README.md Outdated Show resolved Hide resolved
src/Tools/Replay/Replay.csproj Show resolved Hide resolved
src/Tools/Replay/Replay.cs Outdated Show resolved Hide resolved
src/Tools/Replay/Replay.cs Show resolved Hide resolved
Roslyn.sln Outdated Show resolved Hide resolved
NuGet.config Outdated Show resolved Hide resolved
jaredpar and others added 3 commits March 20, 2024 11:20
Co-authored-by: Fred Silberberg <fred@silberberg.xyz>
Compilers.slnf Outdated Show resolved Hide resolved
src/Tools/Replay/Replay.cs Outdated Show resolved Hide resolved
Co-authored-by: Fred Silberberg <fred@silberberg.xyz>
@jaredpar
Copy link
Member Author

@RikkiGibson, @jjonescz PTAL

@RikkiGibson RikkiGibson self-assigned this Mar 21, 2024
src/Tools/Replay/README.md Outdated Show resolved Hide resolved
src/Tools/Replay/README.md Outdated Show resolved Hide resolved
var stopwatch = new Stopwatch();
stopwatch.Start();

var compilerCalls = ReadAllCompilerCalls(options.BinlogPath);
Copy link
Member

Choose a reason for hiding this comment

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

Should reading compiler calls be outside the stopwatch?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch. Yeah that call should be fast compared to compilation times but the point is to measure compilation time so should move this out.

jaredpar and others added 2 commits March 21, 2024 08:27
Co-authored-by: Jan Jones <jan.jones.cz@gmail.com>

var options = new Mono.Options.OptionSet()
{
{ "b|binlogPath=", "The binary log to relpay", v => binlogPath = v },
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
{ "b|binlogPath=", "The binary log to relpay", v => binlogPath = v },
{ "b|binlogPath=", "The binary log to replay", v => binlogPath = v },

@jaredpar jaredpar merged commit 35aea35 into dotnet:main Mar 21, 2024
27 of 30 checks passed
@jaredpar jaredpar deleted the replay branch March 21, 2024 18:35
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Mar 21, 2024
@RikkiGibson RikkiGibson removed this from the Next milestone Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Infrastructure untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants