dotnet-inspect-performance
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesedotnet-inspect: performance analysis and triage
dotnet-inspect:性能分析与调优
Use this skill to find the members worth optimizing or hardening first in a .NET
assembly, and to triage them against actionable rewrite shapes. This analysis is
experimental; section names and signal sets may change between releases.
bash
dnx dotnet-inspect -y -- <command>使用此工具可在.NET程序集中找到最值得优先优化或强化的成员,并针对可落地的重构模式对它们进行分类调优。本分析功能为实验性;版本迭代中,章节名称和信号集可能会发生变化。
bash
dnx dotnet-inspect -y -- <command>Rank by leverage first
优先按影响力排名
Top LeverageRoot Reachbash
dnx dotnet-inspect -y -- library MyLib.dll -S "Top Leverage"
dnx dotnet-inspect -y -- type MyType --library MyLib.dll --all -S "Top Leverage"Ranking rows carry a copyable selector, , and .
Add to include non-public members.
StableVisibilitySelector--allTop LeverageRoot Reachbash
dnx dotnet-inspect -y -- library MyLib.dll -S "Top Leverage"
dnx dotnet-inspect -y -- type MyType --library MyLib.dll --all -S "Top Leverage"排名行包含可复制的选择器、(可见性)和(选择器)。添加参数可包含非公开成员。
StableVisibilitySelector--allTriage against rewrite shapes
针对重构模式进行调优
Library triage is split into kind-scoped sections under
(, , , and more). Start with discovery or counts, then select the group or
one concrete kind. Type/member scope keeps the focused
lens.
@PerformancePerformance: BoxingPerformance: ArraysPerformance: Closures and delegatesPerformance Triagebash
dnx dotnet-inspect -y -- library MyLib.dll -D @Performance
dnx dotnet-inspect -y -- library MyLib.dll -S @Performance --count
dnx dotnet-inspect -y -- library MyLib.dll -S "Performance: Boxing" --jsonl
dnx dotnet-inspect -y -- library MyLib.dll -S "Performance:*" \
--loop --min-confidence high --top 20 --tsv
dnx dotnet-inspect -y -- library MyLib.dll \
--triage-shape scan-method-in-loop-call,linq-scan-in-loop,string-build-in-loop \
--top 20 --tsv
dnx dotnet-inspect -y -- library MyLib.dll --triage-shape capturing-delegate --top 10 --jsonlTarget IL-visible costs (allocations: box, newarr, delegate newobj,
ToArray/ToList/Concat), not JIT-handled concerns (isinst/castclass folding,
devirtualization, bounds-check elimination, null-check folding).
Use for repeated hot costs, for a
confidence floor, for one or more shapes, and for the
curated ranked prefix. Supplying any of those flags selects the applicable
performance lens automatically. In library row formats,
flattens two or more populated kind sections into one table with a leading
column. If filtering leaves one populated kind, row formats use that
kind's concrete schema without ; use structured when the kind
discriminator must remain explicit. also includes heterogeneous
sections, so use it for discovery, counts, Markdown, or JSON documents instead.
narrows ranked data before rendering; caps rendered rows
afterward. Common shapes
include , , ,
, (a linear-scan helper invoked
from a caller loop), (a loop-invariant /
that can be hoisted), , ,
, and . Query the algorithmic shapes
explicitly: stays low-confidence because static
analysis cannot prove that the scanned sequence grows with the caller's loop,
so a pass intentionally excludes it.
--loop--min-confidence high|medium|low--triage-shape--top NPerformance:*KindKind--json@Performance--top--rows Ncapturing-delegatebox-value-typesmall-arraylinq-scan-in-loopscan-method-in-loop-callmaterialize-in-loopToArrayToListstring-build-in-loopenumerator-allocationasync-state-machineallocation-hotspotscan-method-in-loop-call--min-confidence highFor registry, pipeline, or object-graph construction that does not match a local
rewrite shape, opt into the aggregate allocation fanout:
bash
dnx dotnet-inspect -y -- library MyLib.dll \
--triage-shape allocation-fanout \
--order-by "OncePaths desc" --top 20 --tsvDirect SitesOnce PathsOpaque PathsExact rows retain machine-readable provenance from the native Analysis
producer in structured JSON:
, ( or ),
,
, , and . Use these fields for runtime/static joins or to
carry one triage row into the matching / confirmation workflow
without parsing text:
CandidateFindinganalysis.allocationanalysis.call-siteProvenance=exactOperationTokenILdifftimelineEvidencebash
dnx dotnet-inspect -y -- library MyLib.dll -S "Performance:*" \
--where "Finding=analysis.allocation" --where "Operation=box" --json
dnx dotnet-inspect -y -- library MyLib.dll -S "Performance:*" \
--where "Finding=analysis.call-site" --jsonAggregate rows such as use and have
a candidate id but no exact source Finding, operation, or token.
flags an instruction-level row that did not join to the
expected producer census.
allocation-hotspotProvenance=aggregatept~Provenance=unmatched类库调优在下按类型划分为不同章节(、、等)。先从发现或统计开始,再选择分组或具体类型。类型/成员范围会保持聚焦的(性能调优)视角。
@PerformancePerformance: BoxingPerformance: ArraysPerformance: Closures and delegatesPerformance Triagebash
dnx dotnet-inspect -y -- library MyLib.dll -D @Performance
dnx dotnet-inspect -y -- library MyLib.dll -S @Performance --count
dnx dotnet-inspect -y -- library MyLib.dll -S "Performance: Boxing" --jsonl
dnx dotnet-inspect -y -- library MyLib.dll -S "Performance:*" \\
--loop --min-confidence high --top 20 --tsv
dnx dotnet-inspect -y -- library MyLib.dll \\
--triage-shape scan-method-in-loop-call,linq-scan-in-loop,string-build-in-loop \\
--top 20 --tsv
dnx dotnet-inspect -y -- library MyLib.dll --triage-shape capturing-delegate --top 10 --jsonl针对IL可见的开销(分配:装箱、newarr、委托newobj、ToArray/ToList/Concat),而非JIT处理的问题(isinst/castclass折叠、去虚拟化、边界检查消除、空检查折叠)。
使用查找重复的热点开销,设置置信度下限,指定一种或多种模式,筛选排名靠前的精选数据。提供上述任一参数会自动选择适用的性能分析视角。在类库行格式中,会将两个或多个已填充的类型章节合并为一个带有(类型)列的表格。如果过滤后仅剩一个已填充的类型,行格式会使用该类型的具体架构,不再显示列;当必须明确区分类型时,请使用结构化的参数。还包含异构章节,因此可将其用于发现、统计、Markdown或JSON文档。会在渲染前缩小排名数据范围;会在渲染后限制显示的行数。常见模式包括、、、、(从调用者循环中调用的线性扫描助手)、(可提升到循环外的循环不变量/)、、、和。可显式查询算法模式:的置信度较低,因为静态分析无法证明扫描序列会随调用者循环增长,因此的筛选会有意排除它。
--loop--min-confidence high|medium|low--triage-shape--top NPerformance:*KindKind--json@Performance--top--rows Ncapturing-delegatebox-value-typesmall-arraylinq-scan-in-loopscan-method-in-loop-callmaterialize-in-loopToArrayToListstring-build-in-loopenumerator-allocationasync-state-machineallocation-hotspotscan-method-in-loop-call--min-confidence high对于不匹配本地重构模式的注册表、管道或对象图构造,可选择聚合分配扇出:
bash
dnx dotnet-inspect -y -- library MyLib.dll \\
--triage-shape allocation-fanout \\
--order-by "OncePaths desc" --top 20 --tsvDirect SitesOnce PathsOpaque Paths精确行在结构化JSON中保留了来自原生Analysis生成器的机器可读来源信息:(候选对象)、(发现结果,或)、(来源=精确)、(操作)、(令牌)和。可使用这些字段进行运行时/静态关联,或将调优行带入匹配的/确认工作流,而无需解析(证据)文本:
CandidateFindinganalysis.allocationanalysis.call-siteProvenance=exactOperationTokenILdifftimelineEvidencebash
dnx dotnet-inspect -y -- library MyLib.dll -S "Performance:*" \\
--where "Finding=analysis.allocation" --where "Operation=box" --json
dnx dotnet-inspect -y -- library MyLib.dll -S "Performance:*" \\
--where "Finding=analysis.call-site" --json聚合行(如)使用(来源=聚合),并带有候选ID,但没有精确的来源发现结果、操作或令牌。(来源=不匹配)标记未与预期生成器统计数据匹配的指令级行。
allocation-hotspotProvenance=aggregatept~Provenance=unmatchedSelect direct caller-loop repetition
选择直接调用者循环重复情况
A once-per-call allocation can still be repeated by an upstream caller's loop.
Select rows with an exact direct invocation receipt:
bash
dnx dotnet-inspect -y -- library MyLib.dll -S "Performance:*" \
--where "CallerLoop=direct" --jsonCallerLoopDepthCallerLoopWitnessLoopOnly resolved invocation edges qualify. Function loads and callback
registration do not prove callback execution, and recursive traversal does not
prove realized depth or frequency. Do not infer either case into caller-loop
evidence; require runtime evidence or a stronger product-owned invocation
contract.
单次调用的分配仍可能被上游调用者的循环重复执行。选择具有精确直接调用记录的行:
bash
dnx dotnet-inspect -y -- library MyLib.dll -S "Performance:*" \\
--where "CallerLoop=direct" --jsonCallerLoopDepthCallerLoopWitnessLoop只有已解析的调用边符合条件。函数加载和回调注册不能证明回调已执行,递归遍历也不能证明实际深度或频率。不要将这两种情况推断为调用者循环证据;需要运行时证据或更明确的产品级调用契约。
Triage exception-path pool churn
调优异常路径池消耗
Select the explicit library section to find
acquisitions whose exact def-use path reaches an external-input boundary before
modeled cleanup:
Resource TriageArrayPool<T>bash
dnx dotnet-inspect -y -- library MyLib.dll -S "Resource Triage" --jsonlTreat as a profiling and hardening candidate, not a
permanent-memory-leak or memory-corruption accusation. Static analysis proves
the unprotected boundary shape and API evidence, not runtime frequency. Use
, , , ,
and to retain exact provenance while drilling the method. Each
boundary is one row; a multi-boundary candidate repeats its candidate and
acquisition fields so every operation stays paired with its own IL offset.
pool-churn-on-exceptionCandidateFinding=analysis.resource-lifecycleAcquire ILBoundary ILBoundaryNot every shape is a pure hot-path win. is reported as
amortized (low confidence) unless the allocation sits in a loop: async lowering
moves work into a state object rather than eliminating it, often once per
call/enumeration/subscription. Treat amortized rows as context, and confirm a
real per-item cost with a profiler before optimizing.
async-state-machine选择显式的(资源调优)类库章节,可找到获取操作中,其精确的定义-使用路径在模型化清理前到达外部输入边界的情况:
Resource TriageArrayPool<T>bash
dnx dotnet-inspect -y -- library MyLib.dll -S "Resource Triage" --jsonl将视为分析和强化的候选对象,而非永久内存泄漏或内存损坏的指控。静态分析可证明未受保护的边界模式和API证据,但无法证明运行时频率。使用、、(获取IL)、(边界IL)和(边界)在排查方法时保留精确来源信息。每个边界对应一行;多边界候选对象会重复其候选和获取字段,以便每个操作都与自己的IL偏移量配对。
pool-churn-on-exceptionCandidateFinding=analysis.resource-lifecycleAcquire ILBoundary ILBoundary并非所有模式都能直接提升热点路径性能。(异步状态机)会被报告为摊销(低置信度),除非分配位于循环中:异步降级会将工作转移到状态对象中,而非消除它,通常每次调用/枚举/订阅发生一次。将摊销行视为上下文信息,在优化前需使用分析器确认实际的每项成本。
async-state-machineConfirm when an allocation appeared
确认分配出现的时间
Correlate one method's native allocation census across caller-selected package
cells:
bash
dnx dotnet-inspect -y -- timeline --package MyLib@1.0.0..2.0.0 \
-t MyType -m HotPath \
--finding analysis.allocation --at first --at lastRepeat for sparse probes or use for an explicitly bounded
dense traversal. These probes locate a candidate old/new boundary; they do not
establish onset. Confirm one method's adjacent pair with Analysis's native
allocation Findings:
--at--at allbash
dnx dotnet-inspect -y -- diff --package MyLib@1.4.0..1.5.0 \
-t MyType -m HotPath \
--finding analysis.allocationThe method target must resolve at one or both endpoints.
confirms an allocation occurrence was introduced, while , ,
and identify a wrong boundary, disappearance, or changed allocation
facets. The command does not traverse versions; the caller owns the search
policy and bound.
PairFinding.AddedPresentRemovedChanged在调用者选择的包版本范围内关联某方法的原生分配统计数据:
bash
dnx dotnet-inspect -y -- timeline --package MyLib@1.0.0..2.0.0 \\
-t MyType -m HotPath \\
--finding analysis.allocation --at first --at last重复使用进行稀疏探测,或使用进行明确边界的密集遍历。这些探测用于定位候选对象的新旧边界;但无法确定起始时间。使用Analysis的原生分配发现结果确认某方法的相邻版本对:
--at--at allbash
dnx dotnet-inspect -y -- diff --package MyLib@1.4.0..1.5.0 \\
-t MyType -m HotPath \\
--finding analysis.allocation目标方法必须在一个或两个端点解析。(配对发现结果:新增)确认分配已引入,而(存在)、(移除)和(变更)则标识错误边界、消失或分配方面的变更。该命令不会遍历版本;调用者需自行制定搜索策略和边界。
PairFinding.AddedPresentRemovedChangedTrace a likely cause to a new call
追踪可能的原因到新调用
After confirming an allocation boundary, compare the same caller method's
direct-call census:
bash
dnx dotnet-inspect -y -- diff --package MyLib@1.4.0..1.5.0 \
-t MyType -m HotPath \
--finding analysis.call-siteThe target method is the caller and each row identifies a callee.
confirms a new call occurrence, such as a newly introduced
. can show that an existing call moved into a loop
or changed dispatch/opcode facets. Use the single-version section while
probing versions; use this final adjacent comparison as the onset proof.
PairFinding.AddedEnumerable.ToArrayChangedCalls确认分配边界后,比较同一调用者方法的直接调用统计数据:
bash
dnx dotnet-inspect -y -- diff --package MyLib@1.4.0..1.5.0 \\
-t MyType -m HotPath \\
--finding analysis.call-site目标方法是调用者,每行标识一个被调用者。确认新调用已引入,例如新添加的。可显示现有调用已移入循环或调度/操作码方面已变更。在探测版本时使用单版本的(调用)章节;使用此最终相邻比较作为起始证明。
PairFinding.AddedEnumerable.ToArrayChangedCallsDrill a candidate
排查候选对象
Call Graph--fields--tree--mermaid--markdown --mermaid--tsv--jsonlbash
dnx dotnet-inspect -y -- member MyType Method:1 --library MyLib.dll -S "Call Graph,Facts"
dnx dotnet-inspect -y -- member MyType Method:1 --library MyLib.dll -S "Call Graph" --fields "Throw,Catch,Finally"
dnx dotnet-inspect -y -- member MyType Method:1 --library MyLib.dll -S "Call Graph" --fields "Alloc,Loop" --tree
dnx dotnet-inspect -y -- member MyType Method:1 --library MyLib.dll -S "Call Graph" --jsonlCall Graph--fields--tree--mermaid--markdown --mermaid--tsv--jsonlbash
dnx dotnet-inspect -y -- member MyType Method:1 --library MyLib.dll -S "Call Graph,Facts"
dnx dotnet-inspect -y -- member MyType Method:1 --library MyLib.dll -S "Call Graph" --fields "Throw,Catch,Finally"
dnx dotnet-inspect -y -- member MyType Method:1 --library MyLib.dll -S "Call Graph" --fields "Alloc,Loop" --tree
dnx dotnet-inspect -y -- member MyType Method:1 --library MyLib.dll -S "Call Graph" --jsonl
```",