scenario-unity-performance

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Unity performance (performance engineer)

Unity 性能优化(performance engineer)

Expert performance work is a measurement discipline: a budget in milliseconds, the bounding thread named before any change, the biggest measured cost fixed first, structure before tuning, and every fix proven with before/after numbers from a development player. An agent does all of it headless:
AgentProfile
in Editor Play mode to iterate,
PerfProbe
in a batch-mode player for verdicts,
PerfCapture
to attribute costs from a Profiler capture,
metal_trace
for GPU time,
PerfBuild
for size. Target: Unity 6000.3.21f1, URP 17.3, macOS Apple Silicon. If a sibling skill named here is missing from your available skills, ask the user to install it (
npx skills add scenario-labs/skills --skill <name>
); unattended, proceed from tool schemas and flag the gap.
REQUIRED BACKGROUND: scenario-unity-expert (channels, review loop, 6.3 traps,
ut_*
toolkit).
专家级性能工作遵循严格的测量纪律:先设定以毫秒计的预算,在任何改动前确定瓶颈所在线程,优先修复实测出的最大成本,先调整结构再调优,并用 development player 的 before/after 数字证明每一项修复。Agent 会以无头方式完成全部工作:在 Editor Play mode 中使用
AgentProfile
迭代,在 batch-mode player 中使用
PerfProbe
得出结论,使用
PerfCapture
归因 Profiler capture 的成本,使用
metal_trace
测量 GPU 时间,使用
PerfBuild
评估包体积。目标环境:Unity 6000.3.21f1、URP 17.3、macOS Apple Silicon。如果这里提到的某个同级 skill 未安装在可用 skills 中,请要求用户安装(
npx skills add scenario-labs/skills --skill <name>
);无人值守时,根据 tool schemas 继续执行并标记该缺口。
必需背景: scenario-unity-expert(channel、review loop、6.3 陷阱、
ut_*
toolkit)。

Stance (the expert delta)

立场(专家视角的差异)

  1. Name the bound before touching anything. "If you speed up the GPU when your profile looks like this it's not going to run any faster" (Peter Hall, Unity Profiler team, _cV1B2hqXGI [00:05:50]). Observed: removing 1.36 MB of garbage per frame did not move a frame bound by 5,946 SetPass calls. GPU bound needs GPU timing; the Frame Debugger has none (Hall [frame 00:09:18]).
  2. Players decide, the Editor iterates. The authority is a development build on the lowest target device (profiling e-book p. 18). GRD: 4.4x in a 2M-instance stress test, 2.07x in the Editor but 1.45x standalone in a real game (Oc6T4hh5gaI [frame 00:12:41]); here the Editor swung 1.5x to 3.0x, players 1.9x to 2.8x on a stress fixture. Forecast about 1.5x.
  3. GC.Alloc sample time is not the cost. Unity records only timestamp and size (e-book p. 27): 54,021 allocations shown as 1.01 ms caused 19.97 ms of
    GC.Collect
    (Hall [frame 00:21:52]). Observed: 27,000 allocations per frame displayed 0.8 to 1.1 ms; the allocating code cost 3.8 to 5.4 ms. Count bytes and calls, measure collections, target 0 B per gameplay frame, and keep the probe itself allocation-free (git-amend ham_w48aRJ4 [00:11:30]).
  4. 6.3 URP draw calls = SRP Batcher + GPU Resident Drawer; the 2024 advice is Built-in-only. Material "Enable GPU Instancing" off, static batching off, no MaterialPropertyBlock (6.3 Manual table). GRD silently does nothing unless BatchRendererGroup Variants = Keep All and every renderer of the URP asset is Forward+ or Deferred+ (URP 17.3 source, observed). Then prove coverage: GRD draws are named "Hybrid Batch Group" in the Frame Debugger (GUI editor only), each other draw is a renderer that fell out (MPB, LPPV, realtime GI, non-DOTS shader, skinned; 6.3 Manual); headless, check eligibility per renderer after
    Start
    .
  5. Data layout first; spreading work over frames hides cost. 200,000 objects: MonoBehaviour Update 27 ms to 0.13 ms through manager, structs, Burst, SoA; "it's just spreading the work around" (Jason Booth, NAVbI1HIzCE [00:06:38]-[00:18:17]).
  6. Attribute every hitch before fixing it, with markers kept in code. Streaming and spawn systems carry their own ProfilerMarkers and counters; Deep Profile only finds what fills a gap (Hall [00:18:39]-[00:19:12]). Compiles show as
    Shader.CreateGPUProgram
    (warm a traced GraphicsStateCollection during loading, Nicolas Borromeo CmD8MVGkDxQ [00:11:14]-[00:14:35]); here warm-up removed all 18 first-use compiles, yet the first frame stayed about 250 ms on
    Mono.JIT
    .
  7. Resident memory kills, untracked usually does not. 0.75 GB untracked was 140 MB resident (Borromeo [00:32:22]); Editor memory is about 5x the player's (Uuzd39AjFWQ [00:10:03]). On a laptop, paging and VRAM overflow are stutter causes of their own.
  8. Counts are exact, times drift [added, observed]. On a shared machine (load average 50 to 210 here), interleave A/B runs and require a consistent sign.
  1. 动任何东西之前先确定瓶颈。 “如果你的 profile 看起来是这样,却去加速 GPU,它不会变得更快”(Peter Hall,Unity Profiler team,_cV1B2hqXGI [00:05:50])。实测:每帧减少 1.36 MB 的 garbage,并未改善一个受 5,946 次 SetPass 调用限制的帧。判定 GPU bound 需要 GPU timing;Frame Debugger 无法提供该数据(Hall [frame 00:09:18])。
  2. Player 作最终判定,Editor 负责迭代。 权威依据是最低目标设备上的 development build(profiling e-book p. 18)。GRD:在 200 万实例压力测试中为 4.4x,在 Editor 中为 2.07x,但同一游戏独立运行时为 1.45x(Oc6T4hh5gaI [frame 00:12:41]);此处 Editor 在 1.5x 到 3.0x 之间波动,而 Player 在压力场景中为 1.9x 到 2.8x。预测约为 1.5x。
  3. GC.Alloc
    采样时间不是成本。
    Unity 只记录时间戳和大小(e-book p. 27):
    GC.Alloc
    显示 54,021 次分配耗时 1.01 ms,却导致
    GC.Collect
    耗时 19.97 ms(Hall [frame 00:21:52])。实测:每帧 27,000 次分配显示为 0.8 到 1.1 ms;执行分配的代码实际耗时 3.8 到 5.4 ms。应统计字节数和调用次数,测量 GC 回收,目标每个 gameplay frame 为 0 B,并确保探针本身不产生分配(git-amend ham_w48aRJ4 [00:11:30])。
  4. 6.3 URP draw calls = SRP Batcher + GPU Resident Drawer;2024 年的建议仅适用于 Built-in。 Material 的 “Enable GPU Instancing” 已关闭,static batching 已关闭,也没有 MaterialPropertyBlock(6.3 Manual 表格)。GRD 除非满足以下条件,否则会静默地不起作用:BatchRendererGroup Variants = Keep All,并且 URP asset 中的每个 renderer 都是 Forward+ 或 Deferred+(URP 17.3 source,实测)。随后验证覆盖率:在 Frame Debugger 中,GRD draw 名为 “Hybrid Batch Group”(仅限 GUI Editor);其余每个 draw 都对应一个发生回退的 renderer(MPB、LPPV、realtime GI、non-DOTS shader、skinned;6.3 Manual)。在无头模式下,应在
    Start
    后逐个检查 renderer 的 eligibility。
  5. 优先处理数据布局;把工作分散到多帧只会隐藏成本。 200,000 个对象:通过 manager、struct、Burst、SoA,将 MonoBehaviour Update 从 27 ms 降至 0.13 ms;“这只是把工作分散到了不同地方”(Jason Booth,NAVbI1HIzCE [00:06:38]-[00:18:17])。
  6. 修复每次卡顿前先归因,并将 markers 保留在代码中。 Streaming 和 spawn systems 各自带有 ProfilerMarkers 和 counters;Deep Profile 只能找出间隙内发生的耗时(Hall [00:18:39]-[00:19:12])。编译会显示为
    Shader.CreateGPUProgram
    (在加载期间预热已 trace 的 GraphicsStateCollection,Nicolas Borromeo CmD8MVGkDxQ [00:11:14]-[00:14:35]);此处的预热消除了全部 18 次首次使用时的编译,但首帧仍被
    Mono.JIT
    拖住约 250 ms。
  7. 常驻内存会拖垮性能,未跟踪内存通常不会。 0.75 GB untracked 实际对应 140 MB resident(Borromeo [00:32:22]);Editor memory 约为 player 的 5 倍(Uuzd39AjFWQ [00:10:03])。在 laptop 上,paging 和 VRAM overflow 本身就会造成卡顿。
  8. 计数精确,耗时存在漂移 [新增,实测]。 在共享机器上(这里的 load average 为 50 到 210),交错执行 A/B 测试,并要求结果方向保持一致。

Establish first

首先确定

Target platforms and min-spec device per tier; frame budget (16.67 ms desktop, mobile x 0.65); resolution and quality tier; what may change (code only, or art, design, feel); a repeatable benchmark, time-based when judging streaming (a fixed step per frame reaches boundaries sooner after a speed-up) [added]; scripting backend and build type; the machine actually measured (discrete GPU, on power; probe JSON
device
) [added]. Defaults: PC-tier URP asset, 60 fps, 1920x1080, development Mono player for iteration, IL2CPP release for size.
各层级的目标平台和最低规格设备;frame budget(desktop 16.67 ms、mobile x 0.65);resolution 和 quality tier;允许变更的范围(仅代码,或包括美术、设计、手感);可重复的 benchmark,评估 streaming 时应基于时间,因为提速后每帧固定步长会更早触达边界 [新增];scripting backend 和 build type;实际用于测量的机器(discrete GPU、接通电源;probe JSON
device
)[新增]。默认值:PC-tier URP asset、60 fps、1920x1080、用于迭代的 development Mono player,以及用于评估包体积的 IL2CPP release。

Workflow

工作流

  1. Budget and benchmark. GATE: a baseline CSV.
  2. Iterate in the Editor.
    ut_perf.profile
    (render=False isolates scripts),
    ab_profile
    for time deltas. GATE: numbers labeled "Editor, iteration".
  3. Static baseline.
    PerfRendering.Audit
    (batching, GRD eligibility per renderer, graphics jobs per platform, Build Profile, stack traces, upload buffer, culling),
    lint_scripts
    , Project Auditor (
    project_auditor
    , Major first,
    triage_auditor
    keeps per-frame lines),
    PerfAudit.AudioImport
    ,
    bundle_duplicates
    . GATE: findings triaged by call frequency.
  4. Measure the player.
    build_player(development=True)
    ,
    run_player(..., shot=png, markers=[...])
    . GATE:
    draw_calls
    > 0, PNG opened,
    budget_check
    .
  5. Classify the bound. Capture wait markers (
    capture_player
    ,
    analyze_capture
    ), longest vs median frame. GPU:
    metal_trace
    +
    metal_gpu_frames
    (GPU busy and per-pass ms; Rendering Debugger Display Stats in the GUI), then the pixel-bound test (4K vs 1080p, render scale). GATE: bound named with a number.
  6. Attribute.
    attribute_spikes
    (your markers, GC.Collect, compiles, MeshCollider cooking, synchronous reads, physics steps),
    physics_catchup
    ,
    memory_budget
    ,
    density_check
    , allocations per block (
    AllocScope
    ,
    Is.Not.AllocatingGCMemory()
    ), GRD coverage (
    PerfFrameDebug.Capture
    or the window). GATE: top three costs named, no unexplained spike.
  7. Fix one thing at a time, structure first. Scripts: allocations, managers, then Burst. Render CPU: Material Variants, SRP Batcher shaders,
    EnableGpuResidentDrawer
    , one camera, Split graphics jobs on DX12/Vulkan. GPU: dynamic resolution or STP, depth priming and less transparency, LOD where triangles are pixel-sized, post-processing on a fixed slice; shadows with scenario-unity-rendering-lighting. Hitches: async loads, prewarmed pools, PSO warm-up in loading, baked MeshColliders, audio load types, no duplicated bundle dependencies. GATE:
    compare_line
    shows the target down, nothing else up, image parity.
  8. Ship config. IL2CPP release, stripping and code generation chosen, variants stripped against the used set (P15), flags through
    BuildPlayerOptions
    (platform profiles share settings). GATE: build succeeded, size explained, smoke run clean.
  9. Guard. Allocation tests and Performance Testing sample groups per commit, lint on changed scripts. GATE: tests pass.
  1. 预算与 benchmark。 GATE:一份 baseline CSV。
  2. 在 Editor 中迭代。
    ut_perf.profile
    (
    render=False
    可隔离脚本)、
    ab_profile
    用于测量时间差。GATE:数字标注为 “Editor, iteration”。
  3. 静态基线。
    PerfRendering.Audit
    (batching、各 renderer 的 GRD eligibility、各平台的 graphics jobs、Build Profile、stack traces、upload buffer、culling)、
    lint_scripts
    、Project Auditor(
    project_auditor
    ,先处理 Major;
    triage_auditor
    保留逐帧行)、
    PerfAudit.AudioImport
    、
    bundle_duplicates
    。GATE:按调用频率对 findings 进行 triage。
  4. 测量 Player。
    build_player(development=True)
    、
    run_player(..., shot=png, markers=[...])
    。GATE:
    draw_calls
    > 0、PNG 已打开、
    budget_check
    。
  5. 判定瓶颈。 采集 wait markers(
    capture_player
    、
    analyze_capture
    ),比较最长帧与中位帧。GPU:使用
    metal_trace
    +
    metal_gpu_frames
    (GPU busy 和每个 pass 的 ms;在 GUI 中使用 Rendering Debugger Display Stats),然后执行 pixel-bound test(4K vs 1080p、render scale)。GATE:用具体数字明确瓶颈。
  6. 归因。
    attribute_spikes
    (你的 markers、GC.Collect、编译、MeshCollider cooking、同步读取、physics steps)、
    physics_catchup
    、
    memory_budget
    、
    density_check
    、按代码块统计 allocations(
    AllocScope
    、
    Is.Not.AllocatingGCMemory()
    )、GRD coverage(
    PerfFrameDebug.Capture
    或对应窗口)。GATE:明确前三大成本,不存在无法解释的 spike。
  7. 一次只修一件事,并优先调整结构。 脚本:先处理 allocations、managers,再使用 Burst。Render CPU:Material Variants、SRP Batcher shaders、
    EnableGpuResidentDrawer
    、单一 camera、在 DX12/Vulkan 上使用 Split graphics jobs。GPU:dynamic resolution 或 STP、depth priming、减少 transparency、在三角形尺寸接近像素时使用 LOD、将 post-processing 放在固定时间片执行;阴影配合 scenario-unity-rendering-lighting 处理。卡顿:async loads、预热 pool、在加载期间完成 PSO warm-up、使用 baked MeshColliders、选择适当的 audio load type、消除重复的 bundle dependencies。GATE:
    compare_line
    显示目标指标下降,其他指标没有上升,且画面保持一致。
  8. 发布配置。 IL2CPP release、选择适当的 stripping 和 code generation、根据实际使用的 variant 集执行 stripping(P15)、通过
    BuildPlayerOptions
    设置 flags(platform profiles 共享设置)。GATE:build 成功、包体积得到解释、smoke run 无异常。
  9. 防回归。 每次 commit 都运行 allocation tests 和 Performance Testing sample groups,并对修改过的 scripts 执行 lint。GATE:tests 通过。

Numbers

数值

ValueRelative toSource
16.67 / 33.33 ms; x 0.65 mobileframe budget at 60 / 30 fps; thermal headroomprofiling e-book p. 9, 36
0 Bmanaged allocation per gameplay frame6.3 Manual; e-book p. 66
up to about 1 msper-frame cost of incremental GC write barrierse-book p. 69
4.4x / 2.07x / 1.45xGRD gain: 2M-instance stress / game in Editor / same game standaloneOc6T4hh5gaI [frame 00:12:41]
217 / 199 / 176 / 161 fpsDX12 Split / Legacy / plain DX12 / Native graphics jobsOc6T4hh5gaI [frame 00:03:52]
256 verticesbelow it GPU instancing is inefficient: combine instead6.3 Manual
about 250 msone PSO creation stallOc6T4hh5gaI [frame 00:04:48]
4 pixel invocationsper one-pixel triangle (2x2 quads); gate 1 triangle per rendered pixel [added]CmD8MVGkDxQ [00:27:26]
48.55 of 80 msper-frame Debug.Log in a development framexjsqv8nj0cw [00:10:23]
< 200 / > 400 KBaudio: Decompress On Load / Streamingconsole e-book p. 104-105
up to 1 msCPU per extra active camera on mobileconsole e-book p. 89
up to 10 sstartup added by Autoconnect Profilere-book p. 47
50% / 70% / 80% of RAMmemory budget: 2 GB phones / general / dedicated devicesHall; Unity tutorial; e-book
5,946 to 33 SetPass; 58-60 to 5.2-6.2 ms3,000 spheres, MPB tint to 8 Material Variants, dev playerobserved
18 to 0first-use
Shader.CreateGPUProgram
after warming 10 PSOs (3.6 ms at load)
observed
177.9 / 110.5 / 116.3 MBmacOS app: IL2CPP Minimal + speed / IL2CPP High + size / Monoobserved
14.75 M to 0.26 M triangles (7.1 to 0.12 per pixel)400 dense meshes after Mesh LOD, draw calls unchangedobserved
57.1 ms frame =
Spawn.Burst
26.9 ms + 4 compiles; next frame 3 physics steps
burst of 3,000 Instantiate read through its own markerobserved
48-80 ms vs 0 msMeshCollider cooking at spawn vs
Physics.BakeMesh
in a job at load (40 meshes)
observed
33 us vs 2.6-3.9 usper
Debug.Log
, stack traces ScriptOnly vs None (dev player)
observed
2.5 vs 5.8 ms; 1.2x at 4x pixelsGPU busy vs CPU main (Metal System Trace); 4K vs 1080p: not pixel boundobserved
1,944 to 1,002 KBtwo bundles sharing a texture: implicit copies vs a shared bundleobserved
数值相对对象来源
16.67 / 33.33 ms;mobile x 0.6560 / 30 fps 的 frame budget;热余量profiling e-book p. 9, 36
0 B每个 gameplay frame 的托管分配量6.3 Manual;e-book p. 66
最高约 1 msincremental GC write barriers 的每帧成本e-book p. 69
4.4x / 2.07x / 1.45xGRD 提升:200 万实例压力测试 / Editor 中的游戏 / 同一游戏独立运行Oc6T4hh5gaI [frame 00:12:41]
217 / 199 / 176 / 161 fpsDX12 Split / Legacy / 普通 DX12 / Native graphics jobsOc6T4hh5gaI [frame 00:03:52]
256 vertices低于此数量时 GPU instancing 效率不高:应改为合并6.3 Manual
约 250 ms一次 PSO 创建造成的停顿Oc6T4hh5gaI [frame 00:04:48]
4 次 pixel invocation每个单像素三角形(2x2 quads);门槛为每个 rendered pixel 1 个三角形 [新增]CmD8MVGkDxQ [00:27:26]
80 ms 中的 48.55 msdevelopment frame 中逐帧 Debug.Log 的成本xjsqv8nj0cw [00:10:23]
< 200 / > 400 KB音频:Decompress On Load / Streamingconsole e-book p. 104-105
最高 1 msmobile 上每增加一个 active camera 的 CPU 成本console e-book p. 89
最高 10 sAutoconnect Profiler 带来的 startup 增量e-book p. 47
RAM 的 50% / 70% / 80%memory budget:2 GB 手机 / 通用设备 / 专用设备Hall;Unity tutorial;e-book
SetPass 从 5,946 降至 33;耗时从 58-60 ms 降至 5.2-6.2 ms3,000 个 sphere,使用 MPB 着色为 8 个 Material Variants,dev player实测
18 降至 0预热 10 个 PSO 后首次使用的
Shader.CreateGPUProgram
(加载时 3.6 ms)
实测
177.9 / 110.5 / 116.3 MBmacOS app:IL2CPP Minimal + speed / IL2CPP High + size / Mono实测
三角形从 1475 万降至 26 万(每像素从 7.1 降至 0.12)启用 Mesh LOD 后的 400 个密集 meshes,draw calls 不变实测
57.1 ms frame =
Spawn.Burst
26.9 ms + 4 次编译;下一帧执行 3 个 physics steps
通过自身 marker 读取 3,000 次 Instantiate 的 burst实测
48-80 ms 降至 0 msspawn 时进行 MeshCollider cooking,对比在加载时于 job 中调用
Physics.BakeMesh
(40 个 meshes)
实测
33 us 对比 2.6-3.9 us每次
Debug.Log
的成本,dev player 中 stack traces 使用 ScriptOnly 对比 None
实测
2.5 对比 5.8 ms;4 倍 pixels 时为 1.2xGPU busy 对比 CPU main(Metal System Trace);4K 对比 1080p:并非 pixel bound实测
1,944 KB 降至 1,002 KB两个 bundle 共享一张 texture:隐式副本 对比 shared bundle实测

Quality gates

Quality gates

  • Measurable: player
    budget_check
    pass (p95 under budget, no gameplay hitch);
    gc_check
    pass in the player;
    attribute_spikes
    unexplained = 0;
    physics_steps
    at most 1 outside a forced spike;
    memory_budget
    pass;
    density_check
    pass;
    PerfRendering.Audit
    counts.error == 0 and every GRD fallout explained; 0
    Shader.CreateGPUProgram
    after loading; no new Major Project Auditor issue in your code; IL2CPP build within budget.
  • Visual: the player's last frame (
    -perfShot
    ) and Editor captures from the same bookmarks before and after,
    ut_review.compare
    , contact sheet opened; no blank, uniform or magenta frame.
  • 可衡量: player 中
    budget_check
    通过(p95 低于预算、无 gameplay hitch);player 中
    gc_check
    通过;
    attribute_spikes
    的 unexplained = 0;除强制 spike 外,
    physics_steps
    最多为 1;
    memory_budget
    通过;
    density_check
    通过;
    PerfRendering.Audit
    的
    counts.error == 0
    ,且每次 GRD fallout 都有解释;加载后
    Shader.CreateGPUProgram
    为 0;代码中没有新增 Major 级 Project Auditor issue;IL2CPP build 符合预算。
  • 视觉: player 的最后一帧(
    -perfShot
    )以及 before/after 阶段来自相同 bookmarks 的 Editor captures、
    ut_review.compare
    、已打开 contact sheet;没有空白、纯色或洋红色 frame。

Common mistakes

常见错误

MistakeWhat it looks likeFix
Optimizing the side that is not boundfewer allocations, same frame timeclassify first (wait markers, GPU busy, SetPass)
Trusting Editor numbers or one run"3x faster" gone in the playerplayer CSV;
ab_profile
with consistent sign
Benchmarking a batch-mode player that renders nothing0.3 ms frames, 0 draw callsPerfProbe submit +
-perfShot
GRD on, nothing changesdraw calls unchangedKeep All, Forward+/Deferred+, static batching off, fallouts fixed
MaterialPropertyBlock for per-object colorSetPass = draw calls;
StdRender.ApplyShader
dominates
Material Variants;
unity_RendererUserValue
with GRD
Reading GC.Alloc ms as the cost"allocations cost 0.5 ms"count and bytes,
GC.Collect
ms, A/B
A monitor that formats strings each frameGC column never 0preallocated buffers, write once (PerfProbe)
Closure in a rarely taken branchallocations with the feature offmove captured locals into the branch
Deep Profile to find a spikeinflated small functionsmarkers and counters kept in code,
-perfMarkers
GPU tuned from the Frame Debuggerguessed timings
metal_trace
(PIX, Nsight on Windows)
Fixed render scale on a laptopfine cold, hitches when hot or loadeddynamic resolution; STP at a fixed scale only for a fixed pixel bound
Warm-up assumed to fix a first-frame hitchstill 250 mscapture: JIT means IL2CPP, loading means async
Frame-spreading as the fixlower peak, same totalmeasure unamortized first, fix structure
MeshCollider added at runtimespawn spike,
Physics.BakePhysXCollisionMeshData
Physics.BakeMesh
in a job, Prebake Collision Meshes
Development flag set through
EditorUserBuildSettings
every platform profile changed
BuildPlayerOptions
or a build profile asset
Sizing from BuildReport
totalSize
1.9 GB for a 178 MB appshipped folder on disk
InstantiateAsync
as a hitch fix
17 to 83 ms frame laterpool and prewarm behind a transition
Benchmarking the first launch of a new build212 vs 22 msdiscard the first launch
错误表现修复
优化了并非瓶颈的一侧allocations 减少,但 frame time 不变先分类瓶颈(wait markers、GPU busy、SetPass)
相信 Editor 数字或只运行一次“3x faster”在 player 中消失使用 player CSV;用
ab_profile
验证结果方向一致
benchmark 不渲染任何内容的 batch-mode player0.3 ms frames,0 draw callsPerfProbe submit +
-perfShot
GRD 已开启,但没有任何变化draw calls 不变Keep All、Forward+/Deferred+、关闭 static batching、修复 fallouts
使用 MaterialPropertyBlock 设置每个对象的颜色SetPass = draw calls;
StdRender.ApplyShader
占主导
Material Variants;结合 GRD 使用
unity_RendererUserValue
把
GC.Alloc
的 ms 当成成本
“allocations cost 0.5 ms”统计次数和字节数、
GC.Collect
ms、A/B
监视器每帧格式化字符串GC column 始终不为 0预分配 buffers,只写入一次(PerfProbe)
极少进入的分支中存在 closure功能关闭时仍产生 allocations将捕获的局部变量移入该分支
使用 Deep Profile 查找 spikesmall functions 的耗时被放大在代码中保留 markers 和 counters,使用
-perfMarkers
根据 Frame Debugger 调优 GPUtiming 只能靠猜测
metal_trace
(Windows 上使用 PIX、Nsight)
在 laptop 上使用固定 render scale冷机时正常,发热或负载较高时出现卡顿dynamic resolution;仅在固定 pixel bound 时按固定 scale 使用 STP
误以为 warm-up 能解决首帧卡顿仍然需要 250 mscapture 后判断:JIT 意味着 IL2CPP,loading 意味着 async
把 frame-spreading 当作修复峰值降低,但总成本不变先测量未摊销成本,再修复结构
运行时添加 MeshColliderspawn spike,
Physics.BakePhysXCollisionMeshData
在 job 中调用
Physics.BakeMesh
,预烘焙 Collision Meshes
通过
EditorUserBuildSettings
设置 development flag
每个 platform profile 都被更改
BuildPlayerOptions
或 build profile asset
使用 BuildReport
totalSize
估算包体积
178 MB 的 app 被算成 1.9 GB检查磁盘上的 shipped folder
将
InstantiateAsync
当作卡顿修复
后续 frame 从 17 ms 增至 83 ms在 transition 期间使用 pool 和 prewarm
benchmark 新 build 的首次启动212 ms 对比 22 ms丢弃首次启动数据

What not to change without sign-off

未经签核不得更改的内容

Game feel (fixed timestep, Maximum Allowed Timestep, animation timing, input, AI ticks); art direction (texture sizes, lights, LOD thresholds, render scale) without before/after captures; the pipeline, engine version or an ECS rewrite; incremental GC off unless gameplay allocates 0 B in the player and an A/B shows the gain;
asyncUploadBufferSize
raised blindly (never returned, console e-book p. 31); VSync off in release; the benchmark path between before and after.
Game feel(fixed timestep、Maximum Allowed Timestep、animation timing、input、AI ticks);art direction(texture 大小、lights、LOD thresholds、render scale),除非有 before/after captures;pipeline、engine version 或 ECS rewrite;关闭 incremental GC,除非 player 中的 gameplay allocation 为 0 B 且 A/B 证明有收益;盲目提高
asyncUploadBufferSize
(从未回退,console e-book p. 31);在 release 中关闭 VSync;更改 before/after 之间的 benchmark path。

Handoffs

交接

  • Receives: the brief in numbers from scenario-unity-expert; systems code from scenario-unity-architecture and scenario-unity-gameplay; pipeline assets from scenario-unity-rendering-lighting; shaders from scenario-unity-shaders; effects from scenario-unity-vfx; UI from scenario-unity-ui; bundles and Addressables from scenario-unity-pipeline-automation.
  • Delivers: the bound, attributed costs, before/after tables, CSVs, traces, PNGs: variant stripping to scenario-unity-shaders, lighting, shadow and post cuts to scenario-unity-rendering-lighting, overdraw budgets to scenario-unity-vfx and scenario-unity-ui, physics settings to scenario-unity-gameplay, duplicate fixes, CI perf tests and build profiles to scenario-unity-pipeline-automation, device and thermal validation to scenario-unity-mobile, Web limits to scenario-unity-web.
  • 接收: 来自 scenario-unity-expert 的数字化 brief;来自 scenario-unity-architecture 和 scenario-unity-gameplay 的 systems code;来自 scenario-unity-rendering-lighting 的 pipeline assets;来自 scenario-unity-shaders 的 shaders;来自 scenario-unity-vfx 的 effects;来自 scenario-unity-ui 的 UI;来自 scenario-unity-pipeline-automation 的 bundles 和 Addressables。
  • 交付: 瓶颈结论、归因后的成本、before/after 表格、CSVs、traces、PNGs;向 scenario-unity-shaders 交付 variant stripping;向 scenario-unity-rendering-lighting 交付 lighting、shadow 和 post 削减方案;向 scenario-unity-vfx 和 scenario-unity-ui 交付 overdraw budgets;向 scenario-unity-gameplay 交付 physics settings;向 scenario-unity-pipeline-automation 交付 duplicate 修复、CI perf tests 和 build profiles;向 scenario-unity-mobile 交付 device 和 thermal validation;向 scenario-unity-web 交付 Web limits。

Unity 6.3 notes

Unity 6.3 说明

  • SRP Batcher + GRD + GPU occlusion (the 17.3 URP asset holds the occlusion flag); dynamic batching deprecated in 6.5, obsolete in 6.6.
  • Split graphics jobs is the default on DX12/Vulkan/consoles (Oc6T4hh5gaI [00:03:04]); the 6.3 URP template reads Windows on/Split, Android off/Native, Metal off/Native; per-platform getters are internal (observed).
  • GraphicsStateCollection
    is experimental, traces only in development players; WebGPU tracing in 6.4.
    FrameDebuggerUtility
    is internal.
  • Profile Analyzer 1.4.0, Memory Profiler 1.1.12, Project Auditor 1.0.2 (built in from 6.4), Performance Testing 3.5.0 (core in 6.6) and Profiling Core 1.0.3 (needed for
    ProfilerCounterValue
    ) are preinstalled packages added by name.
  • Mesh LOD is 6.2+.
    Physics.BakeMesh(int, bool)
    is obsolete: pass
    mesh.GetEntityId()
    . 6.3 runs Boehm (non-generational); CoreCLR is future work.
  • SRP Batcher + GRD + GPU occlusion(17.3 URP asset 包含 occlusion flag);dynamic batching 在 6.5 中弃用,并在 6.6 中过时。
  • Split graphics jobs 是 DX12/Vulkan/consoles 的默认设置(Oc6T4hh5gaI [00:03:04]);6.3 URP template 读取 Windows on/Split、Android off/Native、Metal off/Native;per-platform getters 是 internal(实测)。
  • GraphicsStateCollection
    属于 experimental,仅 development players 中支持 trace;WebGPU tracing 在 6.4 中提供。
    FrameDebuggerUtility
    是 internal。
  • Profile Analyzer 1.4.0、Memory Profiler 1.1.12、Project Auditor 1.0.2(从 6.4 起内置)、Performance Testing 3.5.0(从 6.6 起成为 core)和 Profiling Core 1.0.3(
    ProfilerCounterValue
    所需)都是按名称添加的预装 packages。
  • Mesh LOD 为 6.2+。
    Physics.BakeMesh(int, bool)
    已过时:应传入
    mesh.GetEntityId()
    。6.3 使用 Boehm(non-generational);CoreCLR 属于未来工作。

References

参考资料

  • references/procedures.md
    : eighteen procedures with full calls, each with its live test and recorded result.
  • references/expert-notes.md
    : principles by expert with timestamps, disagreements and deciding conditions.
  • references/critique.md
    : the rubric for judging a performance pass.
  • references/gui-paths.md
    : Profiler, Frame Debugger, Rendering Debugger, Project Auditor and settings paths.
  • references/sources.md
    : every source with credentials, URLs, best timestamps and revision history.
  • scripts/ut_perf.py
    (runner side),
    scripts/AgentKit/Performance/*.cs
    (Editor jobs),
    scripts/Runtime/Performance/*.cs
    (PerfProbe, AllocScope).
  • references/procedures.md
    :18 个包含完整调用的 procedure,每个均附实时 test 和记录结果。
  • references/expert-notes.md
    :按专家整理的原则,附时间戳、分歧点和决策条件。
  • references/critique.md
    :用于评判 performance pass 的 rubric。
  • references/gui-paths.md
    :Profiler、Frame Debugger、Rendering Debugger、Project Auditor 和设置路径。
  • references/sources.md
    :所有来源的凭据、URL、最佳时间戳和修订历史。
  • scripts/ut_perf.py
    (runner side)、
    scripts/AgentKit/Performance/*.cs
    (Editor jobs)、
    scripts/Runtime/Performance/*.cs
    (PerfProbe、AllocScope)。