Build perf diagnostics

From managedcode/dotnet-skills · View interactive version

Build perf diagnostics is an AI agent skill from the GitHub repository managedcode/dotnet-skills. Diagnose MSBuild bottlenecks from binlog timelines and Target/Task Performance Summaries after baseline measurements. USE FOR: unknown build slowness, RAR >5s, analyzers >30% of Csc, a target >50% of build, node utilization below 80%, excessive Copy, restore overhead. DO NOT USE FOR: within-build du

How to use this skill

Skill file

Performance Analysis Methodology

  1. Generate a binlog: dotnet build /bl:{} -m
  2. Use the binlog MCP server (Microsoft.AITools.BinlogMcp, exposed under the binlog MCP namespace) which is bundled with this plugin

If the server cannot connect, use troubleshoot-binlog-mcp when startup repair is

wanted. If repair is blocked, declined, or unnecessary, use the replay flow below.

Alternate flow when MCP is unavailable: binlog replay to text logs

  1. Generate a binlog: dotnet build /bl:{} -m
  2. Replay to diagnostic log with performance summary:

```bash

dotnet msbuild build.binlog -noconlog -fl "-flp:v=diag;logfile=full.log;performancesummary"

```

  1. Read the performance summary (at the end of full.log):

```bash

grep "Target Performance Summary\|Task Performance Summary" -A 50 full.log

```

  1. Find expensive targets and tasks: The PerformanceSummary section lists all targets/tasks sorted by cumulative time
  2. Check for node utilization: grep for scheduling and node messages

```bash

grep -i "node.*assigned\|building with\|scheduler" full.log | head -30

```

  1. Check analyzers: grep for analyzer timing

```bash

grep -i "analyzer.*elapsed\|Total analyzer execution time\|CompilerAnalyzerDriver" full.log

```

Key Metrics and Thresholds

Common Bottlenecks

1. ResolveAssemblyReference (RAR) Slowness

2. Roslyn Analyzers and Source Generators

3. Serialization Bottlenecks (Single-threaded targets)

4. Excessive File I/O (Copy tasks)

5. Evaluation Overhead

6. NuGet Restore in Build

7. Large Project Count and Graph Shape

Using Binlog Replay for Performance Analysis

Step-by-step workflow using text log replay:

  1. Replay with performance summary:

```bash

dotnet msbuild build.binlog -noconlog -fl "-flp:v=diag;logfile=full.log;performancesummary"

```

  1. Read target/task performance summaries (at the end of full.log):

```bash

grep "Target Performance Summary\|Task Performance Summary" -A 50 full.log

```

This shows all targets and tasks sorted by cumulative time — equivalent to finding expensive targets/tasks.

  1. Find per-project build times:

```bash

grep "done building project\|Project Performance Summary" full.log

```

  1. Check parallelism (multi-node scheduling):

```bash

grep -i "node.*assigned\|RequiresLeadingNewline\|Building with" full.log | head -30

```

  1. Check analyzer overhead:

```bash

grep -i "Total analyzer execution time\|analyzer.*elapsed\|CompilerAnalyzerDriver" full.log

```

  1. Drill into a specific slow target:

```bash

grep 'Target "CoreCompile"\|Target "ResolveAssemblyReferences"' full.log

```

Quick Wins Checklist

Impact Categorization

When reporting findings, categorize by impact to help prioritize fixes:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.