Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问许可证需确认审计通过

build-perf-diagnostics构建性能诊断

Agent Skill

build-perf-diagnostics 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

5,441

周安装

229

GitHub Stars

1,481

下载量

1,905
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:build-perf-diagnostics(构建性能诊断)
来源仓库:https://github.com/dotnet/skills
仓库路径:skills/build-perf-diagnostics
安装命令:
npx skills add https://github.com/dotnet/skills --skill build-perf-diagnostics
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/dotnet/skills --skill build-perf-diagnostics

简介

用于分析构建性能日志,识别昂贵目标和任务,优化 MSBuild 调度效率。

  • 适合在 Codex、Claude、Cursor、Gemini CLI 中使用 binlog 诊断构建瓶颈。
  • 通过 npx skills add 命令从 GitHub 安装,需生成 binlog 并使用 dotnet msbuild 回放分析。
  • 注意权限范围和维护状态,避免触发不必要的联网、命令执行或文件写入操作。
  • build-perf-diagnostics 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Performance Analysis Methodology

  1. Generate a binlog: dotnet build /bl:{} -m
  2. Replay to diagnostic log with performance summary: dotnet msbuild build.binlog -noconlog -fl -flp:v=diag;logfile=full.log;performancesummary
  3. Read the performance summary (at the end of full.log): grep "Target Performance Summary\|Task Performance Summary" -A 50 full.log
  4. Find expensive targets and tasks: The PerformanceSummary section lists all targets/tasks sorted by cumulative time
  5. Check for node utilization: grep for scheduling and node messages grep -i "node.*assigned\|building with\|scheduler" full.log | head -30
  6. Check analyzers: grep for analyzer timing grep -i "analyzer.*elapsed\|Total analyzer execution time\|CompilerAnalyzerDriver" full.log

Key Metrics and Thresholds

  • Build duration: what's "normal" — small project <10s, medium <60s, large <5min
  • Node utilization: ideal is >80% active time across nodes. Low utilization = serialization bottleneck
  • Single target domination: if one target is >50% of build time, investigate
  • Analyzer time vs compile time: analyzers should be <30% of Csc task time. If higher, consider removing expensive analyzers
  • RAR time: ResolveAssemblyReference >5s is concerning. >15s is pathological

Common Bottlenecks

1. ResolveAssemblyReference (RAR) Slowness

  • Symptoms: RAR taking >5s per project
  • Root causes: too many assembly references, network-based reference paths, large assembly search paths
  • Fixes: reduce reference count, use <DesignTimeBuild>false</DesignTimeBuild> for RAR-heavy analysis, set <ResolveAssemblyReferencesSilent>true</ResolveAssemblyReferencesSilent> for diagnostic
  • Advanced: <DesignTimeBuild> and <ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
  • Key insight: RAR runs unconditionally even on incremental builds because users may have installed targeting packs or GACed assemblies (see dotnet/msbuild#2015). With.NET Core micro-assemblies, the reference count is often very high.
  • Reduce transitive references: Set <DisableTransitiveProjectReferences>true</DisableTransitiveProjectReferences> to avoid pulling in the full transitive closure (note: projects may need to add direct references for any types they consume). Use ReferenceOutputAssembly="false" on ProjectReferences that are only needed at build time (not API surface). Trim unused PackageReferences.

2. Roslyn Analyzers and Source Generators

  • Symptoms: Csc task takes much longer than expected for file count (>2× clean compile time)
  • Diagnosis: Check the Task Performance Summary in the replayed log for Csc task time; grep for analyzer timing messages; compare Csc duration with and without analyzers (/p:RunAnalyzers=false)
  • Fixes:

- Conditionally disable in dev: <RunAnalyzers Condition="'$(ContinuousIntegrationBuild)'!= 'true'">false</RunAnalyzers> - Per-configuration: <RunAnalyzers Condition="'$(Configuration)' == 'Debug'">false</RunAnalyzers> - Code-style only: <EnforceCodeStyleInBuild Condition="'$(ContinuousIntegrationBuild)' == 'true'">true</EnforceCodeStyleInBuild> - Remove genuinely redundant analyzers from inner loop - Severity config in.editorconfig for less critical rules

  • Key principle: Preserve analyzer enforcement in CI. Never just "remove" analyzers — configure them conditionally.
  • GlobalPackageReference: Analyzers added via GlobalPackageReference in Directory.Packages.props apply to ALL projects. Consider if test projects need the same analyzer set as production code.
  • EnforceCodeStyleInBuild: When set to true in Directory.Build.props, forces code-style analysis on every build. Should be conditional on CI environment (ContinuousIntegrationBuild) to avoid slowing dev inner loop.

3. Serialization Bottlenecks (Single-threaded targets)

  • Symptoms: Performance summary shows most build time concentrated in a single project; diagnostic log shows idle nodes while one works
  • Common culprits: targets without proper dependency declaration, single project on critical path
  • Fixes: split large projects, optimize the critical path project, ensure proper BuildInParallel

4. Excessive File I/O (Copy tasks)

  • Symptoms: Copy task shows high aggregate time
  • Root causes: copying thousands of files, copying across network drives, Copy task unintentionally running once per item (per-file) instead of as a single batch (see dotnet/msbuild#12884)
  • Fixes: use hardlinks (<CreateHardLinksForCopyFilesToOutputDirectoryIfPossible>true</CreateHardLinksForCopyFilesToOutputDirectoryIfPossible>), reduce CopyToOutputDirectory items, use <UseCommonOutputDirectory>true</UseCommonOutputDirectory> when appropriate, set <SkipCopyUnchangedFiles>true</SkipCopyUnchangedFiles>, consider --artifacts-path (.NET 8+) for centralized output layout
  • Dev Drive: On Windows, switching to a Dev Drive (ReFS with copy-on-write and reduced Defender scans) can significantly reduce file I/O overhead for Copy-heavy builds. Recommend for both dev machines and self-hosted CI agents.

5. Evaluation Overhead

  • Symptoms: build starts slow before any compilation
  • Root causes: complex Directory.Build.props, wildcard globs scanning large directories, NuGetSdkResolver overhead (adds 180-400ms per project evaluation even when restored — see dotnet/msbuild#4025)
  • Fixes: reduce Directory.Build.props complexity, use <EnableDefaultItems>false</EnableDefaultItems> for legacy projects with explicit file lists, avoid NuGet-based SDK resolvers if possible
  • See: eval-performance skill for detailed guidance

6. NuGet Restore in Build

  • Symptoms: restore runs every build even when unnecessary
  • Fixes:

- Separate restore from build: dotnet restore then dotnet build --no-restore - Enable static graph evaluation: <RestoreUseStaticGraphEvaluation>true</RestoreUseStaticGraphEvaluation> in Directory.Build.props — can save significant time in large builds (results are workload-dependent)

7. Large Project Count and Graph Shape

  • Symptoms: many small projects, each takes minimal time but overhead adds up; deep dependency chains serialize the build
  • Consider: project consolidation, or use /graph mode for better scheduling
  • Graph shape matters: a wide dependency graph (few levels, many parallel branches) builds faster than a deep one (many levels, serialized). Refactoring from deep to wide can yield significant improvements in both clean and incremental build times.
  • Actions: look for unnecessary project dependencies, consider splitting a bottleneck project into two, or merging small leaf projects

Using Binlog Replay for Performance Analysis

Step-by-step workflow using text log replay:

  1. Replay with performance summary: dotnet msbuild build.binlog -noconlog -fl -flp:v=diag;logfile=full.log;performancesummary
  2. Read target/task performance summaries (at the end of full.log): 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.
  3. Find per-project build times: grep "done building project\|Project Performance Summary" full.log
  4. Check parallelism (multi-node scheduling): grep -i "node.*assigned\|RequiresLeadingNewline\|Building with" full.log | head -30
  5. Check analyzer overhead: grep -i "Total analyzer execution time\|analyzer.*elapsed\|CompilerAnalyzerDriver" full.log
  6. Drill into a specific slow target: grep 'Target "CoreCompile"\|Target "ResolveAssemblyReferences"' full.log

Quick Wins Checklist

  • Use /maxcpucount (or -m) for parallel builds
  • Separate restore from build (dotnet restore then dotnet build --no-restore)
  • Enable static graph restore (<RestoreUseStaticGraphEvaluation>true</RestoreUseStaticGraphEvaluation>)
  • Enable hardlinks for Copy (<CreateHardLinksForCopyFilesToOutputDirectoryIfPossible>true</CreateHardLinksForCopyFilesToOutputDirectoryIfPossible>)
  • Disable analyzers conditionally in dev inner loop: <RunAnalyzers Condition="'$(ContinuousIntegrationBuild)'!= 'true'">false</RunAnalyzers>
  • Enable reference assemblies (<ProduceReferenceAssembly>true</ProduceReferenceAssembly>)
  • Check for broken incremental builds (see incremental-build skill)
  • Check for bin/obj clashes (see check-bin-obj-clash skill)
  • Use graph build (/graph) for multi-project solutions
  • Use --artifacts-path (.NET 8+) for centralized output layout
  • Enable Dev Drive (ReFS) on Windows dev machines and self-hosted CI

Impact Categorization

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

  • 🔴 HIGH IMPACT (do first): Items consuming >10% of total build time, or a single target >50% of build time
  • 🟡 MEDIUM IMPACT: Items consuming 2-10% of build time
  • 🟢 QUICK WINS: Easy changes with modest impact (e.g., property flags in Directory.Build.props)

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

36.35%
按下载量换算692

Claude

27.37%
按下载量换算521

Cursor

16.91%
按下载量换算322

Gemini CLI

10.1%
按下载量换算192

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills