scenario-unity-performance
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseUnity 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: in Editor Play mode to iterate, in a batch-mode player for verdicts, to attribute costs from a Profiler capture, for GPU time, 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 (); unattended, proceed from tool schemas and flag the gap.
AgentProfilePerfProbePerfCapturemetal_tracePerfBuildnpx skills add scenario-labs/skills --skill <name>REQUIRED BACKGROUND: scenario-unity-expert (channels, review loop, 6.3 traps, toolkit).
ut_*专家级性能工作遵循严格的测量纪律:先设定以毫秒计的预算,在任何改动前确定瓶颈所在线程,优先修复实测出的最大成本,先调整结构再调优,并用 development player 的 before/after 数字证明每一项修复。Agent 会以无头方式完成全部工作:在 Editor Play mode 中使用 迭代,在 batch-mode player 中使用 得出结论,使用 归因 Profiler capture 的成本,使用 测量 GPU 时间,使用 评估包体积。目标环境:Unity 6000.3.21f1、URP 17.3、macOS Apple Silicon。如果这里提到的某个同级 skill 未安装在可用 skills 中,请要求用户安装();无人值守时,根据 tool schemas 继续执行并标记该缺口。
AgentProfilePerfProbePerfCapturemetal_tracePerfBuildnpx skills add scenario-labs/skills --skill <name>必需背景: scenario-unity-expert(channel、review loop、6.3 陷阱、 toolkit)。
ut_*Stance (the expert delta)
立场(专家视角的差异)
- 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]).
- 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.
- 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 (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]).
GC.Collect - 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 - 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]).
- 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 (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
Shader.CreateGPUProgram.Mono.JIT - 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.
- 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.
- 动任何东西之前先确定瓶颈。 “如果你的 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])。
- 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。
- 采样时间不是成本。 Unity 只记录时间戳和大小(e-book p. 27):
GC.Alloc显示 54,021 次分配耗时 1.01 ms,却导致GC.Alloc耗时 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])。GC.Collect - 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)。在无头模式下,应在 后逐个检查 renderer 的 eligibility。
Start - 优先处理数据布局;把工作分散到多帧只会隐藏成本。 200,000 个对象:通过 manager、struct、Burst、SoA,将 MonoBehaviour Update 从 27 ms 降至 0.13 ms;“这只是把工作分散到了不同地方”(Jason Booth,NAVbI1HIzCE [00:06:38]-[00:18:17])。
- 修复每次卡顿前先归因,并将 markers 保留在代码中。 Streaming 和 spawn systems 各自带有 ProfilerMarkers 和 counters;Deep Profile 只能找出间隙内发生的耗时(Hall [00:18:39]-[00:19:12])。编译会显示为 (在加载期间预热已 trace 的 GraphicsStateCollection,Nicolas Borromeo CmD8MVGkDxQ [00:11:14]-[00:14:35]);此处的预热消除了全部 18 次首次使用时的编译,但首帧仍被
Shader.CreateGPUProgram拖住约 250 ms。Mono.JIT - 常驻内存会拖垮性能,未跟踪内存通常不会。 0.75 GB untracked 实际对应 140 MB resident(Borromeo [00:32:22]);Editor memory 约为 player 的 5 倍(Uuzd39AjFWQ [00:10:03])。在 laptop 上,paging 和 VRAM overflow 本身就会造成卡顿。
- 计数精确,耗时存在漂移 [新增,实测]。 在共享机器上(这里的 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 ) [added]. Defaults: PC-tier URP asset, 60 fps, 1920x1080, development Mono player for iteration, IL2CPP release for size.
device各层级的目标平台和最低规格设备;frame budget(desktop 16.67 ms、mobile x 0.65);resolution 和 quality tier;允许变更的范围(仅代码,或包括美术、设计、手感);可重复的 benchmark,评估 streaming 时应基于时间,因为提速后每帧固定步长会更早触达边界 [新增];scripting backend 和 build type;实际用于测量的机器(discrete GPU、接通电源;probe JSON )[新增]。默认值:PC-tier URP asset、60 fps、1920x1080、用于迭代的 development Mono player,以及用于评估包体积的 IL2CPP release。
deviceWorkflow
工作流
- Budget and benchmark. GATE: a baseline CSV.
- Iterate in the Editor. (render=False isolates scripts),
ut_perf.profilefor time deltas. GATE: numbers labeled "Editor, iteration".ab_profile - Static baseline. (batching, GRD eligibility per renderer, graphics jobs per platform, Build Profile, stack traces, upload buffer, culling),
PerfRendering.Audit, Project Auditor (lint_scripts, Major first,project_auditorkeeps per-frame lines),triage_auditor,PerfAudit.AudioImport. GATE: findings triaged by call frequency.bundle_duplicates - Measure the player. ,
build_player(development=True). GATE:run_player(..., shot=png, markers=[...])> 0, PNG opened,draw_calls.budget_check - Classify the bound. Capture wait markers (,
capture_player), longest vs median frame. GPU:analyze_capture+metal_trace(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.metal_gpu_frames - Attribute. (your markers, GC.Collect, compiles, MeshCollider cooking, synchronous reads, physics steps),
attribute_spikes,physics_catchup,memory_budget, allocations per block (density_check,AllocScope), GRD coverage (Is.Not.AllocatingGCMemory()or the window). GATE: top three costs named, no unexplained spike.PerfFrameDebug.Capture - Fix one thing at a time, structure first. Scripts: allocations, managers, then Burst. Render CPU: Material Variants, SRP Batcher shaders, , 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:
EnableGpuResidentDrawershows the target down, nothing else up, image parity.compare_line - Ship config. IL2CPP release, stripping and code generation chosen, variants stripped against the used set (P15), flags through (platform profiles share settings). GATE: build succeeded, size explained, smoke run clean.
BuildPlayerOptions - Guard. Allocation tests and Performance Testing sample groups per commit, lint on changed scripts. GATE: tests pass.
- 预算与 benchmark。 GATE:一份 baseline CSV。
- 在 Editor 中迭代。 (
ut_perf.profile可隔离脚本)、render=False用于测量时间差。GATE:数字标注为 “Editor, iteration”。ab_profile - 静态基线。 (batching、各 renderer 的 GRD eligibility、各平台的 graphics jobs、Build Profile、stack traces、upload buffer、culling)、
PerfRendering.Audit、Project Auditor(lint_scripts,先处理 Major;project_auditor保留逐帧行)、triage_auditor、PerfAudit.AudioImport。GATE:按调用频率对 findings 进行 triage。bundle_duplicates - 测量 Player。 、
build_player(development=True)。GATE:run_player(..., shot=png, markers=[...])> 0、PNG 已打开、draw_calls。budget_check - 判定瓶颈。 采集 wait markers(、
capture_player),比较最长帧与中位帧。GPU:使用analyze_capture+metal_trace(GPU busy 和每个 pass 的 ms;在 GUI 中使用 Rendering Debugger Display Stats),然后执行 pixel-bound test(4K vs 1080p、render scale)。GATE:用具体数字明确瓶颈。metal_gpu_frames - 归因。 (你的 markers、GC.Collect、编译、MeshCollider cooking、同步读取、physics steps)、
attribute_spikes、physics_catchup、memory_budget、按代码块统计 allocations(density_check、AllocScope)、GRD coverage(Is.Not.AllocatingGCMemory()或对应窗口)。GATE:明确前三大成本,不存在无法解释的 spike。PerfFrameDebug.Capture - 一次只修一件事,并优先调整结构。 脚本:先处理 allocations、managers,再使用 Burst。Render CPU:Material Variants、SRP Batcher shaders、、单一 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:
EnableGpuResidentDrawer显示目标指标下降,其他指标没有上升,且画面保持一致。compare_line - 发布配置。 IL2CPP release、选择适当的 stripping 和 code generation、根据实际使用的 variant 集执行 stripping(P15)、通过 设置 flags(platform profiles 共享设置)。GATE:build 成功、包体积得到解释、smoke run 无异常。
BuildPlayerOptions - 防回归。 每次 commit 都运行 allocation tests 和 Performance Testing sample groups,并对修改过的 scripts 执行 lint。GATE:tests 通过。
Numbers
数值
| Value | Relative to | Source |
|---|---|---|
| 16.67 / 33.33 ms; x 0.65 mobile | frame budget at 60 / 30 fps; thermal headroom | profiling e-book p. 9, 36 |
| 0 B | managed allocation per gameplay frame | 6.3 Manual; e-book p. 66 |
| up to about 1 ms | per-frame cost of incremental GC write barriers | e-book p. 69 |
| 4.4x / 2.07x / 1.45x | GRD gain: 2M-instance stress / game in Editor / same game standalone | Oc6T4hh5gaI [frame 00:12:41] |
| 217 / 199 / 176 / 161 fps | DX12 Split / Legacy / plain DX12 / Native graphics jobs | Oc6T4hh5gaI [frame 00:03:52] |
| 256 vertices | below it GPU instancing is inefficient: combine instead | 6.3 Manual |
| about 250 ms | one PSO creation stall | Oc6T4hh5gaI [frame 00:04:48] |
| 4 pixel invocations | per one-pixel triangle (2x2 quads); gate 1 triangle per rendered pixel [added] | CmD8MVGkDxQ [00:27:26] |
| 48.55 of 80 ms | per-frame Debug.Log in a development frame | xjsqv8nj0cw [00:10:23] |
| < 200 / > 400 KB | audio: Decompress On Load / Streaming | console e-book p. 104-105 |
| up to 1 ms | CPU per extra active camera on mobile | console e-book p. 89 |
| up to 10 s | startup added by Autoconnect Profiler | e-book p. 47 |
| 50% / 70% / 80% of RAM | memory budget: 2 GB phones / general / dedicated devices | Hall; Unity tutorial; e-book |
| 5,946 to 33 SetPass; 58-60 to 5.2-6.2 ms | 3,000 spheres, MPB tint to 8 Material Variants, dev player | observed |
| 18 to 0 | first-use | observed |
| 177.9 / 110.5 / 116.3 MB | macOS app: IL2CPP Minimal + speed / IL2CPP High + size / Mono | observed |
| 14.75 M to 0.26 M triangles (7.1 to 0.12 per pixel) | 400 dense meshes after Mesh LOD, draw calls unchanged | observed |
57.1 ms frame = | burst of 3,000 Instantiate read through its own marker | observed |
| 48-80 ms vs 0 ms | MeshCollider cooking at spawn vs | observed |
| 33 us vs 2.6-3.9 us | per | observed |
| 2.5 vs 5.8 ms; 1.2x at 4x pixels | GPU busy vs CPU main (Metal System Trace); 4K vs 1080p: not pixel bound | observed |
| 1,944 to 1,002 KB | two bundles sharing a texture: implicit copies vs a shared bundle | observed |
| 数值 | 相对对象 | 来源 |
|---|---|---|
| 16.67 / 33.33 ms;mobile x 0.65 | 60 / 30 fps 的 frame budget;热余量 | profiling e-book p. 9, 36 |
| 0 B | 每个 gameplay frame 的托管分配量 | 6.3 Manual;e-book p. 66 |
| 最高约 1 ms | incremental GC write barriers 的每帧成本 | e-book p. 69 |
| 4.4x / 2.07x / 1.45x | GRD 提升:200 万实例压力测试 / Editor 中的游戏 / 同一游戏独立运行 | Oc6T4hh5gaI [frame 00:12:41] |
| 217 / 199 / 176 / 161 fps | DX12 Split / Legacy / 普通 DX12 / Native graphics jobs | Oc6T4hh5gaI [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 ms | development frame 中逐帧 Debug.Log 的成本 | xjsqv8nj0cw [00:10:23] |
| < 200 / > 400 KB | 音频:Decompress On Load / Streaming | console e-book p. 104-105 |
| 最高 1 ms | mobile 上每增加一个 active camera 的 CPU 成本 | console e-book p. 89 |
| 最高 10 s | Autoconnect 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 ms | 3,000 个 sphere,使用 MPB 着色为 8 个 Material Variants,dev player | 实测 |
| 18 降至 0 | 预热 10 个 PSO 后首次使用的 | 实测 |
| 177.9 / 110.5 / 116.3 MB | macOS app:IL2CPP Minimal + speed / IL2CPP High + size / Mono | 实测 |
| 三角形从 1475 万降至 26 万(每像素从 7.1 降至 0.12) | 启用 Mesh LOD 后的 400 个密集 meshes,draw calls 不变 | 实测 |
57.1 ms frame = | 通过自身 marker 读取 3,000 次 Instantiate 的 burst | 实测 |
| 48-80 ms 降至 0 ms | spawn 时进行 MeshCollider cooking,对比在加载时于 job 中调用 | 实测 |
| 33 us 对比 2.6-3.9 us | 每次 | 实测 |
| 2.5 对比 5.8 ms;4 倍 pixels 时为 1.2x | GPU 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 pass (p95 under budget, no gameplay hitch);
budget_checkpass in the player;gc_checkunexplained = 0;attribute_spikesat most 1 outside a forced spike;physics_stepspass;memory_budgetpass;density_checkcounts.error == 0 and every GRD fallout explained; 0PerfRendering.Auditafter loading; no new Major Project Auditor issue in your code; IL2CPP build within budget.Shader.CreateGPUProgram - Visual: the player's last frame () and Editor captures from the same bookmarks before and after,
-perfShot, contact sheet opened; no blank, uniform or magenta frame.ut_review.compare
- 可衡量: player 中 通过(p95 低于预算、无 gameplay hitch);player 中
budget_check通过;gc_check的 unexplained = 0;除强制 spike 外,attribute_spikes最多为 1;physics_steps通过;memory_budget通过;density_check的PerfRendering.Audit,且每次 GRD fallout 都有解释;加载后counts.error == 0为 0;代码中没有新增 Major 级 Project Auditor issue;IL2CPP build 符合预算。Shader.CreateGPUProgram - 视觉: player 的最后一帧()以及 before/after 阶段来自相同 bookmarks 的 Editor captures、
-perfShot、已打开 contact sheet;没有空白、纯色或洋红色 frame。ut_review.compare
Common mistakes
常见错误
| Mistake | What it looks like | Fix |
|---|---|---|
| Optimizing the side that is not bound | fewer allocations, same frame time | classify first (wait markers, GPU busy, SetPass) |
| Trusting Editor numbers or one run | "3x faster" gone in the player | player CSV; |
| Benchmarking a batch-mode player that renders nothing | 0.3 ms frames, 0 draw calls | PerfProbe submit + |
| GRD on, nothing changes | draw calls unchanged | Keep All, Forward+/Deferred+, static batching off, fallouts fixed |
| MaterialPropertyBlock for per-object color | SetPass = draw calls; | Material Variants; |
| Reading GC.Alloc ms as the cost | "allocations cost 0.5 ms" | count and bytes, |
| A monitor that formats strings each frame | GC column never 0 | preallocated buffers, write once (PerfProbe) |
| Closure in a rarely taken branch | allocations with the feature off | move captured locals into the branch |
| Deep Profile to find a spike | inflated small functions | markers and counters kept in code, |
| GPU tuned from the Frame Debugger | guessed timings | |
| Fixed render scale on a laptop | fine cold, hitches when hot or loaded | dynamic resolution; STP at a fixed scale only for a fixed pixel bound |
| Warm-up assumed to fix a first-frame hitch | still 250 ms | capture: JIT means IL2CPP, loading means async |
| Frame-spreading as the fix | lower peak, same total | measure unamortized first, fix structure |
| MeshCollider added at runtime | spawn spike, | |
Development flag set through | every platform profile changed | |
Sizing from BuildReport | 1.9 GB for a 178 MB app | shipped folder on disk |
| 17 to 83 ms frame later | pool and prewarm behind a transition |
| Benchmarking the first launch of a new build | 212 vs 22 ms | discard the first launch |
| 错误 | 表现 | 修复 |
|---|---|---|
| 优化了并非瓶颈的一侧 | allocations 减少,但 frame time 不变 | 先分类瓶颈(wait markers、GPU busy、SetPass) |
| 相信 Editor 数字或只运行一次 | “3x faster”在 player 中消失 | 使用 player CSV;用 |
| benchmark 不渲染任何内容的 batch-mode player | 0.3 ms frames,0 draw calls | PerfProbe submit + |
| GRD 已开启,但没有任何变化 | draw calls 不变 | Keep All、Forward+/Deferred+、关闭 static batching、修复 fallouts |
| 使用 MaterialPropertyBlock 设置每个对象的颜色 | SetPass = draw calls; | Material Variants;结合 GRD 使用 |
把 | “allocations cost 0.5 ms” | 统计次数和字节数、 |
| 监视器每帧格式化字符串 | GC column 始终不为 0 | 预分配 buffers,只写入一次(PerfProbe) |
| 极少进入的分支中存在 closure | 功能关闭时仍产生 allocations | 将捕获的局部变量移入该分支 |
| 使用 Deep Profile 查找 spike | small functions 的耗时被放大 | 在代码中保留 markers 和 counters,使用 |
| 根据 Frame Debugger 调优 GPU | timing 只能靠猜测 | |
| 在 laptop 上使用固定 render scale | 冷机时正常,发热或负载较高时出现卡顿 | dynamic resolution;仅在固定 pixel bound 时按固定 scale 使用 STP |
| 误以为 warm-up 能解决首帧卡顿 | 仍然需要 250 ms | capture 后判断:JIT 意味着 IL2CPP,loading 意味着 async |
| 把 frame-spreading 当作修复 | 峰值降低,但总成本不变 | 先测量未摊销成本,再修复结构 |
| 运行时添加 MeshCollider | spawn spike, | 在 job 中调用 |
通过 | 每个 platform profile 都被更改 | |
使用 BuildReport | 178 MB 的 app 被算成 1.9 GB | 检查磁盘上的 shipped folder |
将 | 后续 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; raised blindly (never returned, console e-book p. 31); VSync off in release; the benchmark path between before and after.
asyncUploadBufferSizeGame 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 证明有收益;盲目提高 (从未回退,console e-book p. 31);在 release 中关闭 VSync;更改 before/after 之间的 benchmark path。
asyncUploadBufferSizeHandoffs
交接
- 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).
- is experimental, traces only in development players; WebGPU tracing in 6.4.
GraphicsStateCollectionis internal.FrameDebuggerUtility - 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 ) are preinstalled packages added by name.
ProfilerCounterValue - Mesh LOD is 6.2+. is obsolete: pass
Physics.BakeMesh(int, bool). 6.3 runs Boehm (non-generational); CoreCLR is future work.mesh.GetEntityId()
- 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(实测)。
- 属于 experimental,仅 development players 中支持 trace;WebGPU tracing 在 6.4 中提供。
GraphicsStateCollection是 internal。FrameDebuggerUtility - 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(所需)都是按名称添加的预装 packages。
ProfilerCounterValue - Mesh LOD 为 6.2+。已过时:应传入
Physics.BakeMesh(int, bool)。6.3 使用 Boehm(non-generational);CoreCLR 属于未来工作。mesh.GetEntityId()
References
参考资料
- : eighteen procedures with full calls, each with its live test and recorded result.
references/procedures.md - : principles by expert with timestamps, disagreements and deciding conditions.
references/expert-notes.md - : the rubric for judging a performance pass.
references/critique.md - : Profiler, Frame Debugger, Rendering Debugger, Project Auditor and settings paths.
references/gui-paths.md - : every source with credentials, URLs, best timestamps and revision history.
references/sources.md - (runner side),
scripts/ut_perf.py(Editor jobs),scripts/AgentKit/Performance/*.cs(PerfProbe, AllocScope).scripts/Runtime/Performance/*.cs
- :18 个包含完整调用的 procedure,每个均附实时 test 和记录结果。
references/procedures.md - :按专家整理的原则,附时间戳、分歧点和决策条件。
references/expert-notes.md - :用于评判 performance pass 的 rubric。
references/critique.md - :Profiler、Frame Debugger、Rendering Debugger、Project Auditor 和设置路径。
references/gui-paths.md - :所有来源的凭据、URL、最佳时间戳和修订历史。
references/sources.md - (runner side)、
scripts/ut_perf.py(Editor jobs)、scripts/AgentKit/Performance/*.cs(PerfProbe、AllocScope)。scripts/Runtime/Performance/*.cs