[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7E6MS5ZZ04SCTRQHBQA2TY9":3,"skill-same:01M7E6MS5ZZ04SCTRQHBQA2TY9":47},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":29,"ownerHtmlUrl":30,"ownerBlogUrl":31,"ownerDescription":6,"updatedAt":32,"install":33,"resources":46},"01M7E6MS5ZZ04SCTRQHBQA2TY9","performance",null,"Use when a Godot game stutters, hitches, drops frames, runs hot, or before a milestone or release where frame rate matters.","nick-vas\u002Fhyperdot","nick-vas","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F7181961?v=4","01M7E6F6F0BQ49V0JZHX9BXCBD","Nikolaos Vasilikiotis","01M7E6F6FZW8SW1AJ1S7ARFE89",1,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fnick-vas\u002Fhyperdot\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fperformance\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: performance\ndescription: Use when a Godot game stutters, hitches, drops frames, runs hot, or before a milestone or release where frame rate matters.\n---\n\n# Frame pacing and performance (Godot 4.7, C#)\n\nBudget, measure, change one thing, measure again. Average FPS hides what players feel; the numbers that matter are\nper-frame times, the slowest frames, and when and where they happen. Sources for the C# measurements:\n`${CLAUDE_PLUGIN_ROOT}\u002Fdocs\u002Fprofiling-and-builds.md`.\n\n## Measure\n\n```powershell\npwsh ${CLAUDE_PLUGIN_ROOT}\u002Fci\u002Fgodot\u002Fhyperdot.ps1 bench -Json -Quiet -Scene res:\u002F\u002Flevels\u002FBoss.tscn -GameArgs '--stress' -Seconds 30 -Warmup 5 -Uncapped -Label \"uncapped 1080p\" -Resolution 1920x1080\npwsh ${CLAUDE_PLUGIN_ROOT}\u002Fci\u002Fgodot\u002Fhyperdot.ps1 bench -Json -Quiet -Scene res:\u002F\u002Flevels\u002FBoss.tscn -GameArgs '--stress' -Seconds 30 -MaxFps 60 -BudgetMs 16.7 -Label \"60 cap\"\n```\n\n`bench` records the wall-clock time of every frame after a warm-up and returns `fps.low1`\u002F`fps.low01` (1% and 0.1% lows),\n`frameMs.p50`\u002F`p99`\u002F`max`, frames over 20 and 33 ms, a `frameHistogram` (shares of frames at 120, 60, 30 and 20 fps or\nslower), a timestamped `hitches[]` log, the slowest places (`hotspots`), draw calls, the scene's load time (`loadMs`, from\n`load()` to its first frame) and every custom monitor's delta.\nEach run appends a labelled row to `bench-results\u002Fbench.csv`, so runs stay comparable. Several benchmark runs are a good job\nfor the `godot-verifier` subagent, which returns the numbers without the logs. `-BudgetMs` fails the run\n(`bench-over-budget`) when p99 is above the budget; `-MaxDrawCalls` (`bench-over-draw-calls`, the average a frame) and\n`-MaxLoadMs` (`bench-over-load-time`) hold the other two budgets.\n\n- **Benchmark the worst case**, not the menu: the heaviest scene with the most on screen. Give the game a flag for it\n  (`--stress`: a boss that never dies, every effect on) and pass it with `-GameArgs` (`automation-hooks`).\n- **Sweep one knob** to find where it crosses the budget: `bench -Sweep enemies=10,50,200 -BudgetMs 16.7` runs once per\n  value with `--enemies=\u003Cn>`, one CSV row each; `sweep.lastWithinLimits` is the last value under the budget.\n- **Uncapped, then capped.** `-Uncapped` (V-Sync off) shows the headroom; `-MaxFps 60` or V-Sync on shows whether pacing is stable.\n- **Skip the warm-up** (`-Warmup`); first frames compile shaders and fill caches.\n- **Use a display.** Without `-Headless`, frames are really drawn. `-Headless` measures CPU time only (draw calls 0) and is what CI can run.\n- **Read the hitch timestamps.** If a hitch moves when you change `-Warmup`, it is a measurement artifact; if it stays tied to a\n  game event (first hit of a fight), it is real.\n- **Find the scripting layer's limits in the first week.** Bench the hot loop (pathfinding, the simulation tick, many\n  bodies) as first written, in GDScript if that is the game's language, and move only what `bench` shows over budget to\n  C# or a server. Toru Hidaka knew BASIC's limits within a month and turned to machine language (*Untold History*).\n\n## Budget per area\n\nBefore optimising, write the budget down: 33.3 ms a frame at 30 fps, 16.7 ms at 60. First take off what every frame pays\n(HUD, post-processing, the player) and a margin of about 2 ms for the day something goes wrong; then split what is left\nper area with whoever owns the art and design, by what the area is for: a combat arena spends it on AI, physics and\neffects, a vista on scenery, a lighting showcase on lights. Bench each area against its own number (`-BudgetMs`, with\n`-Scene` or a `-GameArgs` flag that starts there). An area over budget becomes a task for its owner (`plan -Do add -Title`)\nwith the milliseconds over and several ways to win them back: the owner picks which.\n\n## Where it is slow\n\n```powershell\npwsh ${CLAUDE_PLUGIN_ROOT}\u002Fci\u002Fgodot\u002Fhyperdot.ps1 bench -Json -Quiet -Scene res:\u002F\u002Flevels\u002FCanyon.tscn -GameArgs '--autoplay' -Seconds 120 -HotspotCell 20\n```\n\nA level's frame times say that it is slow, not where; without a place, optimising means wandering the level. `bench` pairs\neach frame with the root viewport's camera (the `Camera3D`'s position, or the screen centre under a `Camera2D`) and\nreturns `hotspots`: grid cells (10 m in 3D, 512 px in 2D, or `-HotspotCell`) with the worst p99 first, each with\n`centre`, `frames`, `p99Ms` and `maxMs`. Each `hitches[]` entry has a `pos` too.\n\n1. Cover the level the same way every run: a bot route, an autoplay flag or a scripted fly-through (`automation-hooks`).\n2. Start at `hotspots[0].centre`. A cell with few `frames` was crossed quickly, so one slow frame sets its p99: read\n   `maxMs` and the hitches there before believing it.\n3. Bench a short run that starts at that place, with a window and `-Uncapped`, and compare `gpuMs.avg` with\n   `frameMs.avg`: GPU time well under the frame time means the CPU is the limit (scripts, physics, AI, spawning); close\n   to it means drawing is.\n4. Fix one thing, run the same route, compare the cell. `camera` `none` (no camera, or one inside a `SubViewport`) gives\n   no places: use `hitches[].t` instead.\n\n## What slow places usually hold\n\nIn Halo 4's last year of optimisation most fixes were content, not code, and kept the look\n(`${CLAUDE_PLUGIN_ROOT}\u002Fdocs\u002Fgdc\u002Fhalo-4-content-performance.md`):\n\n- **Forgotten things.** Dynamic lights left in a corner nobody visits (a few tiny spot lights cost 3 ms of a 33 ms frame), light ranges far\n  bigger than the light looks (`OmniLight3D.OmniRange`, `SpotLight3D.SpotRange`, with `ShadowEnabled`), scenery drawn\n  far beyond where anyone can see it (pull in `VisibilityRangeEnd`, `asset-pipeline`), two post effects doing one job.\n- **One huge mesh.** A terrain or building in one piece is processed whole when a sliver is on screen; Godot culls per\n  `MeshInstance3D`, so cut it into chunks.\n- **Detail too small to see** where the asset is used (made for a close-up, placed far away): delete it or add a LOD.\n- **Transparency where it is not needed.** Cut alpha-blended cards (sky, distant ridges, water) so only the edge strip\n  blends and the inside is opaque; fewer, richer particles instead of many layers (`godot-shaders-vfx`).\n- **General shaders.** Copy a shader for one use and drop the terms that do not show there, or pack channels.\n- **Spawning all at once.** Stagger AI and physics objects spawned before anyone can see them; simplify collision\n  shapes that rays hit often.\n- **Prove it looks the same, blind.** Show the art lead several copies, one optimised; if they cannot pick it out, keep it.\n- **Content players build** cannot be tuned: give them a placement budget.\n\n## C#: zero garbage in the frame loop\n\nA GC collection mid-fight is a hitch. Report collections as a custom monitor so `bench` shows them (`customMonitors`):\n\n```csharp\npublic override void _Ready() =>\n    Performance.AddCustomMonitor(\"game\u002Fgc_gen0\", Callable.From(() => GC.CollectionCount(0)));\npublic override void _ExitTree() => Performance.RemoveCustomMonitor(\"game\u002Fgc_gen0\"); \u002F\u002F or the engine can crash on exit\n```\n\n`delta` should be 0 over a fight. Common allocations:\n\n| Allocates every frame | Instead |\n|---|---|\n| `Input.IsActionPressed(\"jump\")`: a new `StringName` per call | `static readonly StringName Jump = \"jump\";` |\n| reading `Label.Text` to check a value | keep your own field |\n| `new StandardMaterial3D()` per hit flash | create the overlay once per object, re-attach it |\n| a node or tween per particle or damage number | pool `CpuParticles3D` (`Restart()`) and `Label3D`; animate them in one loop |\n| LINQ, string interpolation, closures in `_Process` | plain loops, cached strings |\n\nWatch pause time, not only counts: `Performance.AddCustomMonitor(\"game\u002Fgc_pause_ms\", Callable.From(() =>\nGC.GetTotalPauseDuration().TotalMilliseconds))`. Custom monitors work in release exports; there `TimeProcess` and\n`TimePhysicsProcess` are in seconds and `MemoryStatic` is always 0.\n\n**GC settings do not cure hitches; pooling does.** Measured on 4.7.2 (3000 frames, about 80 MB kept alive, garbage\nthat lives a while):\n\n| Setting | Frames over 8 ms | Worst frame |\n|---|---|---|\n| Default | 58 | 34 to 56 ms |\n| `DOTNET_gcConcurrent=0` | 17 | 128 to 153 ms |\n| `DOTNET_gcServer=1` | 1 | 162 to 172 ms (and a heap per core) |\n| The same work, pooled | 0 | 2.1 ms |\n\nSettings trade many medium pauses for fewer huge ones; SustainedLowLatency left the slow frames as they were, and\nTieredPGO, tiered compilation and ReadyToRun made no measurable difference under light garbage.\nIf you still test one: run from the editor, Godot reads its own runtimeconfig, so only `DOTNET_*` environment\nvariables apply; exported games read the game's, so csproj settings apply there. `\u003CServerGarbageCollector>` is ignored\nin both; `\u003CRuntimeHostConfigurationOption Include=\"System.GC.Server\" Value=\"true\" \u002F>` works.\n\n## Find the cause\n\n- **The editor's Profiler does not see C#** (\"does not currently support C# scripts\"); it shows engine time only. The\n  Visual Profiler times rendering only.\n- **`dotnet-trace`** attaches to a running game (editor run or exported release), with the game's own process id:\n  `dotnet-trace collect -p \u003Cpid> --profile dotnet-sampled-thread-time --duration 00:00:00:10` for where C# time goes,\n  `--profile gc-verbose` for which methods allocate; `dotnet-trace convert x.nettrace --format speedscope` to read it.\n  `dotnet-gcdump collect -p \u003Cpid>` lists what fills the heap. `DOTNET_EnableDiagnostics=0` blocks them.\n- **`dotnet-counters` shows nothing** for a Godot game: Godot starts .NET without a `Main`, so the runtime's counters\n  never start. In a debug build, start them yourself (`using System.Reflection;`), then `dotnet-counters collect -p \u003Cpid> --counters System.Runtime`:\n\n  ```csharp\n  #if DEBUG\n  typeof(System.Diagnostics.Tracing.EventSource).Assembly.GetType(\"System.Diagnostics.Tracing.RuntimeEventSource\")\n      ?.GetMethod(\"Initialize\", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.Invoke(null, null);\n  #endif\n  ```\n- **Engine (C++) time**: Tracy, Perfetto and Instruments need a custom engine build (`scons profiler=tracy\n  profiler_path=...`); official 4.7.2 builds include Perfetto for Android only, and no desktop debug symbols.\n- `--benchmark` and `--benchmark-file` time startup and shutdown only (editor builds), not frames; `bench`'s `loadMs` and\n  `-MaxLoadMs` hold one scene's load time. `--debug-stringnames` prints every `StringName` allocated, which finds per-frame ones from C#.\n\n## First-use hitches are pipeline compiles\n\nA one-frame spike the first time something appears (first enemy hit, first popup) is usually a shader or text pipeline compiling.\n\n- During a loading or intro screen, show one of every visual (enemies, projectiles, pickups, popup text, tinted variants)\n  **tiny but on screen** for a frame, then free it.\n- Pre-rasterise glyphs at every size you use: `font.RenderRange(0, new Vector2I(size, outline), ' ', '~');`. For text that shrinks\n  to fit, fit a sample first to learn the final size.\n\n## Renderer and V-Sync\n\n- If V-Sync is \"on\" but the game runs at thousands of FPS, the driver is ignoring it. One project saw this with the Compatibility\n  (OpenGL) renderer on an NVIDIA driver; Mobile on Vulkan (`rendering\u002Frendering_device\u002Ffallback_to_opengl3=true`) fixed it.\n- Safety net: if V-Sync is on but the first second runs far above the refresh rate, set `Engine.MaxFps` to the refresh rate. A fixed\n  \"refresh + 2\" cap caused beat drops instead.\n- When the GPU or V-Sync is the limit, every queued frame is input lag. Shadow of War's pipeline (simulation, render,\n  driver, GPU, display queue) once put the screen about 200 ms behind the input (Piotr Mintus, GDC 2018); they stretched\n  the simulation 1 ms a frame until the display queue drained. Keep `rendering\u002Frendering_device\u002Fvsync\u002Fframe_queue_size`\n  at its default 2 and measure input lag in the GPU-bound case, not only in the menu.\n- Movement that judders on a 144 Hz screen while the frame rate is fine: a body moved in `_PhysicsProcess` at 60 Hz\n  with `physics\u002Fcommon\u002Fphysics_interpolation` off (the default; `doctor` warns). Turn it on, and call\n  `ResetPhysicsInterpolation()` after a teleport.\n\n## Cheap wins\n\n- `MultiMesh` for repeated static props: one draw call per kind. Watch `drawCalls` in `bench`.\n- Billboards should not cast shadows (their shadow is a flat silhouette).\n- In 3D, VRAM-compressed textures with mipmaps (never for pixel art or UI: `asset-pipeline`); particle textures at\n  most 256 px; audio as mono QOA around 32 kHz.\n- Shadow map 2048 with low soft-shadow quality is enough for a tilted top-down camera.\n- Content that rarely changes (a board drawn on the floor): a `SubViewport` with `UpdateMode.Once`, re-triggered only on change.\n- Scale CPU work from frame time, not only resolution: Shadow of War pushed character LODs out when rendering neared\n  30 ms of a 33 ms frame, and paused streaming high mips if frames still dropped. Past about 90% of the budget for\n  several frames, raise `Viewport.MeshLodThreshold` or pull in `VisibilityRangeEnd`; restore below a lower mark, held\n  longer, so it never flips frame to frame.\n- AI that re-plans, paths or rebuilds influence maps for many agents in one frame: spread it under a fixed per-frame budget\n  (`game-ai`, `FrameBudget`); 200 GOAP re-plans took 4 to 10 ms in one frame here, about 1 ms a frame over 4 to 6.\n\n## A Unity checklist, in Godot 4.7\n\nItems from The Gamedev Guru's *Performance Optimization Checklist* (Unity 2020+, Lite v2) whose Godot counterpart exists\nin 4.7.2 (checked headless); its draw-call targets (\"\u003C 100 on mobile, \u003C 1000 on desktop\") are a starting point for a\nbudget, not Godot measurements.\n\n- \"Restrict cameras' culling mask\": `Camera3D.CullMask` against `VisualInstance3D.Layers`, so a minimap or second\n  camera draws only its layers.\n- \"Use occlusion culling in interiors\": `OccluderInstance3D` does nothing until\n  `rendering\u002Focclusion_culling\u002Fuse_occlusion_culling` is on (default off; `doctor` warns).\n- \"Pause out-of-screen subsystems\": `VisibleOnScreenEnabler2D\u002F3D` stops its target's processing off screen.\n- \"Adapt the budget allocated to physics\": `physics\u002Fcommon\u002Fmax_physics_steps_per_frame` (default 8) caps the steps one\n  frame may catch up on, so a slow frame cannot snowball into ever slower ones.\n- Simple colliders: `ConcavePolygonShape3D` (the importer's `-col`) for static level geometry only; moving bodies get\n  convex or primitive shapes. Give each kind of body its own `CollisionLayer` and a `CollisionMask` with only the\n  pairs that must meet.\n- Baked over real-time light: `LightmapGI` with static lights instead of SDFGI or VoxelGI where the scene allows;\n  `ReflectionProbe.UpdateModeEnum.Once`, not `Always`.\n- \"Avoid multi-pass shaders\": `Material.NextPass` draws the mesh again. \"Don't use GrabPass on mobile\": a shader that\n  reads `hint_screen_texture` copies the screen.\n- Loading screens: a small scene that stays animated while `ResourceLoader.LoadThreadedRequest` loads the next one and\n  `LoadThreadedGetStatus` reports progress. Measure load time too (a test scene and the real one, debug build included).\n\n## Done means\n\nThe worst-case scene meets the budget with V-Sync on and off, at the target resolution, in the window modes you ship (windowed,\nborderless, fullscreen) and every other mode (split screen), with zero GC collections in the frame loop, and no area over\nits own budget. In-game counters and profilers cost time themselves: confirm the final numbers on a release export that\nlogs frame times and little else. Record the `bench.csv` rows in the plan's beta gate\n(`game-plan`) and keep the numbers from before and after each optimisation.\n","# Frame pacing and performance (Godot 4.7, C#)\n\nBudget, measure, change one thing, measure again. Average FPS hides what players feel; the numbers that matter are\nper-frame times, the slowest frames, and when and where they happen. Sources for the C# measurements:\n`${CLAUDE_PLUGIN_ROOT}\u002Fdocs\u002Fprofiling-and-builds.md`.\n\n## Measure\n\n```powershell\npwsh ${CLAUDE_PLUGIN_ROOT}\u002Fci\u002Fgodot\u002Fhyperdot.ps1 bench -Json -Quiet -Scene res:\u002F\u002Flevels\u002FBoss.tscn -GameArgs '--stress' -Seconds 30 -Warmup 5 -Uncapped -Label \"uncapped 1080p\" -Resolution 1920x1080\npwsh ${CLAUDE_PLUGIN_ROOT}\u002Fci\u002Fgodot\u002Fhyperdot.ps1 bench -Json -Quiet -Scene res:\u002F\u002Flevels\u002FBoss.tscn -GameArgs '--stress' -Seconds 30 -MaxFps 60 -BudgetMs 16.7 -Label \"60 cap\"\n```\n\n`bench` records the wall-clock time of every frame after a warm-up and returns `fps.low1`\u002F`fps.low01` (1% and 0.1% lows),\n`frameMs.p50`\u002F`p99`\u002F`max`, frames over 20 and 33 ms, a `frameHistogram` (shares of frames at 120, 60, 30 and 20 fps or\nslower), a timestamped `hitches[]` log, the slowest places (`hotspots`), draw calls, the scene's load time (`loadMs`, from\n`load()` to its first frame) and every custom monitor's delta.\nEach run appends a labelled row to `bench-results\u002Fbench.csv`, so runs stay comparable. Several benchmark runs are a good job\nfor the `godot-verifier` subagent, which returns the numbers without the logs. `-BudgetMs` fails the run\n(`bench-over-budget`) when p99 is above the budget; `-MaxDrawCalls` (`bench-over-draw-calls`, the average a frame) and\n`-MaxLoadMs` (`bench-over-load-time`) hold the other two budgets.\n\n- **Benchmark the worst case**, not the menu: the heaviest scene with the most on screen. Give the game a flag for it\n  (`--stress`: a boss that never dies, every effect on) and pass it with `-GameArgs` (`automation-hooks`).\n- **Sweep one knob** to find where it crosses the budget: `bench -Sweep enemies=10,50,200 -BudgetMs 16.7` runs once per\n  value with `--enemies=\u003Cn>`, one CSV row each; `sweep.lastWithinLimits` is the last value under the budget.\n- **Uncapped, then capped.** `-Uncapped` (V-Sync off) shows the headroom; `-MaxFps 60` or V-Sync on shows whether pacing is stable.\n- **Skip the warm-up** (`-Warmup`); first frames compile shaders and fill caches.\n- **Use a display.** Without `-Headless`, frames are really drawn. `-Headless` measures CPU time only (draw calls 0) and is what CI can run.\n- **Read the hitch timestamps.** If a hitch moves when you change `-Warmup`, it is a measurement artifact; if it stays tied to a\n  game event (first hit of a fight), it is real.\n- **Find the scripting layer's limits in the first week.** Bench the hot loop (pathfinding, the simulation tick, many\n  bodies) as first written, in GDScript if that is the game's language, and move only what `bench` shows over budget to\n  C# or a server. Toru Hidaka knew BASIC's limits within a month and turned to machine language (*Untold History*).\n\n## Budget per area\n\nBefore optimising, write the budget down: 33.3 ms a frame at 30 fps, 16.7 ms at 60. First take off what every frame pays\n(HUD, post-processing, the player) and a margin of about 2 ms for the day something goes wrong; then split what is left\nper area with whoever owns the art and design, by what the area is for: a combat arena spends it on AI, physics and\neffects, a vista on scenery, a lighting showcase on lights. Bench each area against its own number (`-BudgetMs`, with\n`-Scene` or a `-GameArgs` flag that starts there). An area over budget becomes a task for its owner (`plan -Do add -Title`)\nwith the milliseconds over and several ways to win them back: the owner picks which.\n\n## Where it is slow\n\n```powershell\npwsh ${CLAUDE_PLUGIN_ROOT}\u002Fci\u002Fgodot\u002Fhyperdot.ps1 bench -Json -Quiet -Scene res:\u002F\u002Flevels\u002FCanyon.tscn -GameArgs '--autoplay' -Seconds 120 -HotspotCell 20\n```\n\nA level's frame times say that it is slow, not where; without a place, optimising means wandering the level. `bench` pairs\neach frame with the root viewport's camera (the `Camera3D`'s position, or the screen centre under a `Camera2D`) and\nreturns `hotspots`: grid cells (10 m in 3D, 512 px in 2D, or `-HotspotCell`) with the worst p99 first, each with\n`centre`, `frames`, `p99Ms` and `maxMs`. Each `hitches[]` entry has a `pos` too.\n\n1. Cover the level the same way every run: a bot route, an autoplay flag or a scripted fly-through (`automation-hooks`).\n2. Start at `hotspots[0].centre`. A cell with few `frames` was crossed quickly, so one slow frame sets its p99: read\n   `maxMs` and the hitches there before believing it.\n3. Bench a short run that starts at that place, with a window and `-Uncapped`, and compare `gpuMs.avg` with\n   `frameMs.avg`: GPU time well under the frame time means the CPU is the limit (scripts, physics, AI, spawning); close\n   to it means drawing is.\n4. Fix one thing, run the same route, compare the cell. `camera` `none` (no camera, or one inside a `SubViewport`) gives\n   no places: use `hitches[].t` instead.\n\n## What slow places usually hold\n\nIn Halo 4's last year of optimisation most fixes were content, not code, and kept the look\n(`${CLAUDE_PLUGIN_ROOT}\u002Fdocs\u002Fgdc\u002Fhalo-4-content-performance.md`):\n\n- **Forgotten things.** Dynamic lights left in a corner nobody visits (a few tiny spot lights cost 3 ms of a 33 ms frame), light ranges far\n  bigger than the light looks (`OmniLight3D.OmniRange`, `SpotLight3D.SpotRange`, with `ShadowEnabled`), scenery drawn\n  far beyond where anyone can see it (pull in `VisibilityRangeEnd`, `asset-pipeline`), two post effects doing one job.\n- **One huge mesh.** A terrain or building in one piece is processed whole when a sliver is on screen; Godot culls per\n  `MeshInstance3D`, so cut it into chunks.\n- **Detail too small to see** where the asset is used (made for a close-up, placed far away): delete it or add a LOD.\n- **Transparency where it is not needed.** Cut alpha-blended cards (sky, distant ridges, water) so only the edge strip\n  blends and the inside is opaque; fewer, richer particles instead of many layers (`godot-shaders-vfx`).\n- **General shaders.** Copy a shader for one use and drop the terms that do not show there, or pack channels.\n- **Spawning all at once.** Stagger AI and physics objects spawned before anyone can see them; simplify collision\n  shapes that rays hit often.\n- **Prove it looks the same, blind.** Show the art lead several copies, one optimised; if they cannot pick it out, keep it.\n- **Content players build** cannot be tuned: give them a placement budget.\n\n## C#: zero garbage in the frame loop\n\nA GC collection mid-fight is a hitch. Report collections as a custom monitor so `bench` shows them (`customMonitors`):\n\n```csharp\npublic override void _Ready() =>\n    Performance.AddCustomMonitor(\"game\u002Fgc_gen0\", Callable.From(() => GC.CollectionCount(0)));\npublic override void _ExitTree() => Performance.RemoveCustomMonitor(\"game\u002Fgc_gen0\"); \u002F\u002F or the engine can crash on exit\n```\n\n`delta` should be 0 over a fight. Common allocations:\n\n| Allocates every frame | Instead |\n|---|---|\n| `Input.IsActionPressed(\"jump\")`: a new `StringName` per call | `static readonly StringName Jump = \"jump\";` |\n| reading `Label.Text` to check a value | keep your own field |\n| `new StandardMaterial3D()` per hit flash | create the overlay once per object, re-attach it |\n| a node or tween per particle or damage number | pool `CpuParticles3D` (`Restart()`) and `Label3D`; animate them in one loop |\n| LINQ, string interpolation, closures in `_Process` | plain loops, cached strings |\n\nWatch pause time, not only counts: `Performance.AddCustomMonitor(\"game\u002Fgc_pause_ms\", Callable.From(() =>\nGC.GetTotalPauseDuration().TotalMilliseconds))`. Custom monitors work in release exports; there `TimeProcess` and\n`TimePhysicsProcess` are in seconds and `MemoryStatic` is always 0.\n\n**GC settings do not cure hitches; pooling does.** Measured on 4.7.2 (3000 frames, about 80 MB kept alive, garbage\nthat lives a while):\n\n| Setting | Frames over 8 ms | Worst frame |\n|---|---|---|\n| Default | 58 | 34 to 56 ms |\n| `DOTNET_gcConcurrent=0` | 17 | 128 to 153 ms |\n| `DOTNET_gcServer=1` | 1 | 162 to 172 ms (and a heap per core) |\n| The same work, pooled | 0 | 2.1 ms |\n\nSettings trade many medium pauses for fewer huge ones; SustainedLowLatency left the slow frames as they were, and\nTieredPGO, tiered compilation and ReadyToRun made no measurable difference under light garbage.\nIf you still test one: run from the editor, Godot reads its own runtimeconfig, so only `DOTNET_*` environment\nvariables apply; exported games read the game's, so csproj settings apply there. `\u003CServerGarbageCollector>` is ignored\nin both; `\u003CRuntimeHostConfigurationOption Include=\"System.GC.Server\" Value=\"true\" \u002F>` works.\n\n## Find the cause\n\n- **The editor's Profiler does not see C#** (\"does not currently support C# scripts\"); it shows engine time only. The\n  Visual Profiler times rendering only.\n- **`dotnet-trace`** attaches to a running game (editor run or exported release), with the game's own process id:\n  `dotnet-trace collect -p \u003Cpid> --profile dotnet-sampled-thread-time --duration 00:00:00:10` for where C# time goes,\n  `--profile gc-verbose` for which methods allocate; `dotnet-trace convert x.nettrace --format speedscope` to read it.\n  `dotnet-gcdump collect -p \u003Cpid>` lists what fills the heap. `DOTNET_EnableDiagnostics=0` blocks them.\n- **`dotnet-counters` shows nothing** for a Godot game: Godot starts .NET without a `Main`, so the runtime's counters\n  never start. In a debug build, start them yourself (`using System.Reflection;`), then `dotnet-counters collect -p \u003Cpid> --counters System.Runtime`:\n\n  ```csharp\n  #if DEBUG\n  typeof(System.Diagnostics.Tracing.EventSource).Assembly.GetType(\"System.Diagnostics.Tracing.RuntimeEventSource\")\n      ?.GetMethod(\"Initialize\", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.Invoke(null, null);\n  #endif\n  ```\n- **Engine (C++) time**: Tracy, Perfetto and Instruments need a custom engine build (`scons profiler=tracy\n  profiler_path=...`); official 4.7.2 builds include Perfetto for Android only, and no desktop debug symbols.\n- `--benchmark` and `--benchmark-file` time startup and shutdown only (editor builds), not frames; `bench`'s `loadMs` and\n  `-MaxLoadMs` hold one scene's load time. `--debug-stringnames` prints every `StringName` allocated, which finds per-frame ones from C#.\n\n## First-use hitches are pipeline compiles\n\nA one-frame spike the first time something appears (first enemy hit, first popup) is usually a shader or text pipeline compiling.\n\n- During a loading or intro screen, show one of every visual (enemies, projectiles, pickups, popup text, tinted variants)\n  **tiny but on screen** for a frame, then free it.\n- Pre-rasterise glyphs at every size you use: `font.RenderRange(0, new Vector2I(size, outline), ' ', '~');`. For text that shrinks\n  to fit, fit a sample first to learn the final size.\n\n## Renderer and V-Sync\n\n- If V-Sync is \"on\" but the game runs at thousands of FPS, the driver is ignoring it. One project saw this with the Compatibility\n  (OpenGL) renderer on an NVIDIA driver; Mobile on Vulkan (`rendering\u002Frendering_device\u002Ffallback_to_opengl3=true`) fixed it.\n- Safety net: if V-Sync is on but the first second runs far above the refresh rate, set `Engine.MaxFps` to the refresh rate. A fixed\n  \"refresh + 2\" cap caused beat drops instead.\n- When the GPU or V-Sync is the limit, every queued frame is input lag. Shadow of War's pipeline (simulation, render,\n  driver, GPU, display queue) once put the screen about 200 ms behind the input (Piotr Mintus, GDC 2018); they stretched\n  the simulation 1 ms a frame until the display queue drained. Keep `rendering\u002Frendering_device\u002Fvsync\u002Fframe_queue_size`\n  at its default 2 and measure input lag in the GPU-bound case, not only in the menu.\n- Movement that judders on a 144 Hz screen while the frame rate is fine: a body moved in `_PhysicsProcess` at 60 Hz\n  with `physics\u002Fcommon\u002Fphysics_interpolation` off (the default; `doctor` warns). Turn it on, and call\n  `ResetPhysicsInterpolation()` after a teleport.\n\n## Cheap wins\n\n- `MultiMesh` for repeated static props: one draw call per kind. Watch `drawCalls` in `bench`.\n- Billboards should not cast shadows (their shadow is a flat silhouette).\n- In 3D, VRAM-compressed textures with mipmaps (never for pixel art or UI: `asset-pipeline`); particle textures at\n  most 256 px; audio as mono QOA around 32 kHz.\n- Shadow map 2048 with low soft-shadow quality is enough for a tilted top-down camera.\n- Content that rarely changes (a board drawn on the floor): a `SubViewport` with `UpdateMode.Once`, re-triggered only on change.\n- Scale CPU work from frame time, not only resolution: Shadow of War pushed character LODs out when rendering neared\n  30 ms of a 33 ms frame, and paused streaming high mips if frames still dropped. Past about 90% of the budget for\n  several frames, raise `Viewport.MeshLodThreshold` or pull in `VisibilityRangeEnd`; restore below a lower mark, held\n  longer, so it never flips frame to frame.\n- AI that re-plans, paths or rebuilds influence maps for many agents in one frame: spread it under a fixed per-frame budget\n  (`game-ai`, `FrameBudget`); 200 GOAP re-plans took 4 to 10 ms in one frame here, about 1 ms a frame over 4 to 6.\n\n## A Unity checklist, in Godot 4.7\n\nItems from The Gamedev Guru's *Performance Optimization Checklist* (Unity 2020+, Lite v2) whose Godot counterpart exists\nin 4.7.2 (checked headless); its draw-call targets (\"\u003C 100 on mobile, \u003C 1000 on desktop\") are a starting point for a\nbudget, not Godot measurements.\n\n- \"Restrict cameras' culling mask\": `Camera3D.CullMask` against `VisualInstance3D.Layers`, so a minimap or second\n  camera draws only its layers.\n- \"Use occlusion culling in interiors\": `OccluderInstance3D` does nothing until\n  `rendering\u002Focclusion_culling\u002Fuse_occlusion_culling` is on (default off; `doctor` warns).\n- \"Pause out-of-screen subsystems\": `VisibleOnScreenEnabler2D\u002F3D` stops its target's processing off screen.\n- \"Adapt the budget allocated to physics\": `physics\u002Fcommon\u002Fmax_physics_steps_per_frame` (default 8) caps the steps one\n  frame may catch up on, so a slow frame cannot snowball into ever slower ones.\n- Simple colliders: `ConcavePolygonShape3D` (the importer's `-col`) for static level geometry only; moving bodies get\n  convex or primitive shapes. Give each kind of body its own `CollisionLayer` and a `CollisionMask` with only the\n  pairs that must meet.\n- Baked over real-time light: `LightmapGI` with static lights instead of SDFGI or VoxelGI where the scene allows;\n  `ReflectionProbe.UpdateModeEnum.Once`, not `Always`.\n- \"Avoid multi-pass shaders\": `Material.NextPass` draws the mesh again. \"Don't use GrabPass on mobile\": a shader that\n  reads `hint_screen_texture` copies the screen.\n- Loading screens: a small scene that stays animated while `ResourceLoader.LoadThreadedRequest` loads the next one and\n  `LoadThreadedGetStatus` reports progress. Measure load time too (a test scene and the real one, debug build included).\n\n## Done means\n\nThe worst-case scene meets the budget with V-Sync on and off, at the target resolution, in the window modes you ship (windowed,\nborderless, fullscreen) and every other mode (split screen), with zero GC collections in the frame loop, and no area over\nits own budget. In-game counters and profilers cost time themselves: confirm the final numbers on a release export that\nlogs frame times and little else. Record the `bench.csv` rows in the plan's beta gate\n(`game-plan`) and keep the numbers from before and after each optimisation.\n",{"name":5,"description":7},"main","5fa4c2262d814d50f72198a95b8c483ff195f90f",".agents\u002Fskills\u002Fperformance",0,"https:\u002F\u002Fgithub.com\u002Fnick-vas\u002Fhyperdot","https:\u002F\u002Fnick-vas.github.io\u002Fhyperdot\u002F","https:\u002F\u002Fgithub.com\u002Fnick-vas","https:\u002F\u002Fcommon-beef.itch.io\u002F","2026-11-13 18:55:29",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add nick-vas\u002Fhyperdot --skill performance",{"tool":39,"command":40},"bunx","bunx skills add nick-vas\u002Fhyperdot --skill performance",{"tool":42,"command":43},"pnpm","pnpm dlx skills add nick-vas\u002Fhyperdot --skill performance","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fnick-vas\u002Fhyperdot\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fperformance\u002FSKILL.md",true,[],[48,55,61,68,75,82],{"skillNo":49,"name":50,"nameZh":6,"description":51,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":52,"categories":53,"keywords":54,"publishedAt":19},"01M7E6RF2S03S92PB9RZB4S4W0","over-budget","Use when a fixture exceeds the size budget.","https:\u002F\u002Fgithub.com\u002Fnick-vas\u002Fhyperdot\u002Fblob\u002Fmain\u002Ftests\u002Fskill-fixtures\u002Fover-budget\u002FSKILL.md",[],[],{"skillNo":56,"name":57,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":58,"categories":59,"keywords":60,"publishedAt":19},"01M7E6RBY8SDNMA3ZARE8MAH0G","bad-yaml","https:\u002F\u002Fgithub.com\u002Fnick-vas\u002Fhyperdot\u002Fblob\u002Fmain\u002Ftests\u002Fskill-fixtures\u002Fbad-yaml\u002FSKILL.md",[],[],{"skillNo":62,"name":63,"nameZh":6,"description":64,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":19},"01M7E6R9S9YHTC552SR41RQAJ1","bad-workflow-description","Use when testing; runs the kit and then reads the JSON.","https:\u002F\u002Fgithub.com\u002Fnick-vas\u002Fhyperdot\u002Fblob\u002Fmain\u002Ftests\u002Fskill-fixtures\u002Fbad-workflow-description\u002FSKILL.md",[],[],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":19},"01M7E6R6CWSAN48C80130CM1AK","bad-version","Use when a fixture quotes a stale package version.","https:\u002F\u002Fgithub.com\u002Fnick-vas\u002Fhyperdot\u002Fblob\u002Fmain\u002Ftests\u002Fskill-fixtures\u002Fbad-version\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":19},"01M7E6R2C0E24TC133ESHKZT9R","bad-value","Use when a fixture passes a value outside a parameter's set.","https:\u002F\u002Fgithub.com\u002Fnick-vas\u002Fhyperdot\u002Fblob\u002Fmain\u002Ftests\u002Fskill-fixtures\u002Fbad-value\u002FSKILL.md",[],[],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":19},"01M7E6QYM81V061X7DSQ94CZRP","bad-trigger","Helps with Godot tests.","https:\u002F\u002Fgithub.com\u002Fnick-vas\u002Fhyperdot\u002Fblob\u002Fmain\u002Ftests\u002Fskill-fixtures\u002Fbad-trigger\u002FSKILL.md",[],[]]