Purpose
Measure before optimizing and reduce work at the source: frequency × cost × fanout.
Workflow
- Identify the hot path and expected frequency/fanout.
- Measure idle and active client resmon when possible; use server/client profiler for CPU hotspots.
- Reduce unconditional
Wait(0)loops via events, zones, adaptive sleeps, or caching. - Cache stable native results but invalidate correctly.
- Batch/throttle events, NUI messages, and state updates.
- Reduce entity churn and expensive world scans.
- Eliminate N+1/repeated DB queries and add indexes as supported by workload.
- Profile NUI long tasks/rerenders/layout thrash for complex UIs.
Standalone safety
- Treat client/NUI input as untrusted. Security-sensitive state is server-authoritative.
- Never invent natives, framework APIs, events, exports, or schema. Verify against project code or official docs.
- Completion requires verification proportional to risk.
Deterministic helper
Run python scripts/scan_hotpaths.py <repo-root> as a static lead generator for loops, NUI messages, and state writes. Confirm runtime cost with resmon/profiler before calling something a performance defect.
Skill-specific guardrails
- Do not optimize based only on line count.
- Do not cache dynamic values without invalidation design.
- Do not claim success without before/after evidence for material performance work.
Done criteria
- Bottleneck is measured or strongly evidenced.
- Optimization preserves correctness.
- Before/after metrics or a reproducible measurement plan is provided.
Output contract
When this skill materially affects a task, leave a concise implementation/review note covering: decisions made, files/contracts affected, risks checked, and verification performed. Do not dump the skill text into the user-facing answer.
Reference policy
Prefer project source and authoritative documentation over memory for version-sensitive APIs. See references/performance-checklist.md in this skill for the profiling checklist. When documentation and installed project code disagree, target the installed version.