Skip to content

t1k:unity:dots-core:performance

FieldValue
Moduledots-core
Version2.3.2
Effortmedium
Tools

Keywords: DOTS, optimization, performance, profiling

/t1k:unity:dots-core:performance

Coding patterns: see /dots-ecs (Performance Priority section). Job specifics: see /dots-jobs-burst. Draw calls / batching: see /dots-graphics (RenderMeshArray, SRP Batcher, GPU instancing).

Context7 sources: /needle-mirror/com.unity.entities (query optimization), /needle-mirror/com.unity.burst (Burst best practices), /websites/unity3d_packages_com_unity_collections_2_6 (collection perf).

Never optimize without data. Profile → identify → fix → verify.

IMPORTANT: rendering_stats is NOT a direct MCP tool. Call via batch_execute:
batch_execute(commands=[{"tool":"rendering_stats","params":{"action":"get_stats"}}])
1. rendering_stats(get_stats) → FPS, draw calls, batches
2. rendering_stats(get_memory) → mono heap, graphics driver, reserved
3. rendering_stats(get_system_stats, top_n=30) → per-DOTS-system CPU breakdown (avg/max/p95/% frame)
4. identify the ONE worst bottleneck
5. fix it, re-profile, confirm improvement

Post-Session Analysis (No Play Mode Required)

Section titled “Post-Session Analysis (No Play Mode Required)”

Sessions auto-save as JSON on Play exit → Logs/PerfSessions/perf-YYYYMMDD-HHmmss.json.

1. rendering_stats(list_sessions) → list saved session files
2. rendering_stats(analyze_session, → bottleneck report: HIGH/MEDIUM
filename="perf-YYYYMMDD-HHmmss.json") severity issues, top 30 systems

Session JSON contains: FPS avg/min/max/p95, CPU avg/min/max/p95, top 30 systems by CPU, 500-point timeline, scene name, duration, peak entity count.

Regression workflow: record baseline session → implement optimization → record again → analyze_session both → compare top-system rankings.

→ See profiling-workflow-guide.md for step-by-step post-session workflow.

TopicFileCoverage
MCP profiling workflowprofiling-workflow-guide.mdLive MCP steps, post-session analysis, verification checklist, mandatory reporting
Parallelization & queriesparallelization-guide.mdJob decision tree, SystemAPI random access fix, query optimization, Burst tips
Navigation performancenavigation-perf-guide.mdNav scaling, dead agent cleanup, tier throttling, FixedStep, NavMesh gotchas
Memory & collectionsmemory-patterns-guide.mdAnti-patterns, SharedStatic, SpatialHash, chunk utilization, InternalBufferCapacity

SRP Batcher (free, always-on for URP):

  • Requires all objects share the same shader variant
  • Anti-pattern: MaterialPropertyBlock per-instance disables SRP Batcher

GPU Instancing via ECS:

  • RenderMeshArray + MaterialMeshInfo enable automatic instancing
  • Each unique (mesh, material, layer) = separate draw call bucket — minimize combinations
  • Tag components that change render state (color, emission) must use MaterialProperty attribute

Static batching for terrain/walls:

  • Walls use per-segment LODGroup with impostor billboard at LOD1 — no mesh combining needed
  • Do NOT combine meshes that need individual LODGroups or physics colliders

Transparent materials cause per-entity draw calls (CRITICAL): URP entities with _SURFACE_TYPE_TRANSPARENT get DepthSorted_Tag from Entities Graphics, forcing per-entity back-to-front rendering. This defeats SRP Batcher AND GPU instancing. Fix: Use AlphaTest (cutout) with _AlphaClip=1 + _Cutoff=0.5 instead of Transparent for sprites/quads. Only use Transparent for genuinely semi-transparent effects (particles, AoE blasts). In BattleDemo2D this reduced 608 to 28 batches (95.4%).

Anti-PatternFixReference
Optimizing without profilingMeasure First (Rule #1)This file
SystemAPI.GetComponent in foreachCache ComponentLookup<T> in OnCreateparallelization-guide.md
Allocating NativeList per entity per frameHoist before foreach, Clear each iterationmemory-patterns-guide.md
Dead agents processing through all nav systemsDeadAgentStopSystem disables NavMeshPathnavigation-perf-guide.md
AIUpdateTierSystem counting allies for distanceFilter by team in distance checksnavigation-perf-guide.md
Transparent materials on spritesUse AlphaTest (cutout) insteadThis file
Optimizing without saving a reportAlways save to plans/reports/profiling-workflow-guide.md