How to Profile CPU Spikes From Spawn Waves in Unity 6 and Godot 4 Without Guesswork
Spawn waves are where many indie action games quietly fall apart. The game feels fine with 5 enemies, maybe even 20, then one wave starts and frame time jumps hard. The common trap is "fixing what looks expensive" instead of proving what is expensive.
This guide gives you a repeatable profiling workflow for Unity 6 and Godot 4 so you can isolate spawn-wave CPU spikes, apply the right fix, and verify that the gain survives build conditions.
If you are already working through related systems, keep these nearby:
- How to Build a Reusable Enemy Spawn Director in Unity 6 and Godot 4 - Wave Curves Budgets and Cooldowns
- Unity 6.7 Beta Graphics Regressions in 2026 - A 48-Hour Verification Plan Before You Touch Mainline
- Performance Debugging in Godot 4
- Performance Optimization and Profiling

Why spawn-wave spikes are hard to debug
Wave spikes are usually a stacked event, not one bad line:
- object creation bursts
- AI initialization in the same frame
- pathing updates syncing at spawn time
- animation graph warm-up
- first-time VFX/audio allocations
If you only inspect average frame time, you miss the spike shape and blame the wrong system.
Step 1 - Build one deterministic test route
Before opening any profiler, create a stable test:
- same map section
- same spawn timing
- same wave size
- same player behavior (or scripted replay)
Your goal is to compare captures against a fixed baseline. Without deterministic input, every profile is a different experiment.
Pro tip: Keep one "wave stress scene" checked into source control. Treat it as a performance unit test.
Step 2 - Capture in the right environment
Editor captures are useful, but not final truth.
Run at least:
- one editor profile for fast iteration
- one development build profile for realism
Spawn waves often look fine in editor and regress in build due to different threading behavior, stripping, or content loading paths.
Step 3 - Tag the wave boundary in code
Do not scroll timelines guessing where wave start happened. Add explicit markers/log boundaries.
For Unity, use profiler markers around:
- wave scheduler tick
- spawn loop
- post-spawn initialization
For Godot, add consistent log timestamps or custom monitor counters around the same boundaries.
This turns "somewhere around here" into exact timing windows.
Step 4 - Split spike analysis into three buckets
When a spike appears, classify it first:
1) Spawn burst cost
Instantiation, scene-tree attach, component setup.
2) First-frame simulation cost
AI state boot, path requests, physics registration.
3) Side-effect cost
VFX, audio, UI updates, telemetry events.
Most teams waste hours because they try to optimize rendering when the spike is actually first-frame AI boot plus pathfinding fan-out.
Unity 6 quick triage pattern
In Unity 6 Profiler:
- locate the frame spike around wave marker
- inspect main thread and worker threads separately
- expand scripts and job timelines for spawn frame
- note top 3 contributors by milliseconds
Common Unity wave offenders:
- pooled objects still doing heavy
OnEnablework - multiple systems subscribing/unsubscribing per spawn
- nav/path calls firing for all enemies in one frame
- animation controller parameter setup spikes
Fix strategy that usually works:
- stagger heavy init across several frames
- prewarm path/animation assets before wave
- batch lightweight setup, defer expensive setup
Godot 4 quick triage pattern
In Godot 4:
- use the Profiler and Monitor views during deterministic wave run
- compare frame-time spikes against node creation and physics activity
- inspect script hotspots in spawn and
_readypaths - test spawn batch size reductions to see spike shape change
Common Godot offenders:
- large
PackedScene.instantiate()bursts in one tick - expensive
_ready()logic on every enemy - signal wiring done repeatedly with extra allocations
- navigation or collision updates synchronized on spawn
Fix strategy that usually works:
- staged spawn queue instead of one-frame flood
- move heavy setup out of
_ready()where possible - cache shared references/resources before wave
- spread path requests over a short window
Step 5 - Verify the fix with A/B capture
Never trust one "good-looking" run.
Do:
- baseline capture (before fix)
- variant capture (after fix)
- same deterministic route
- compare p95/p99 frame time around wave windows
If spike moved from frame 220 to frame 228, but stayed equally large, you did not solve it. You delayed it.
Fast checklist before merging performance fixes
Use this pass before shipping:
- spike reduced in both editor and development build
- no new hitch introduced in later wave
- memory allocation pattern not worsened
- fix documented with capture screenshot or timing notes
- one rollback note if fix touches spawn architecture
Common mistakes to avoid
- optimizing average FPS instead of spike frames
- profiling with inconsistent test routes
- mixing multiple fixes before measuring each one
- trusting editor-only captures as final evidence
- ignoring p95/p99 in favor of one clean frame
FAQ
Should I solve spawn spikes with pooling only
Pooling helps, but it is not enough if pooled objects still perform expensive initialization when activated. Measure activation cost, not just instantiation cost.
How many frames should I spread spawn initialization over
Start small: 3 to 8 frames for heavy waves. Then profile. The right number depends on game feel and enemy behavior requirements.
What is a good target metric for wave smoothness
For action games, focus on p95 and p99 frame-time stability during waves, not only average FPS. Stable worst-case frames matter more than pretty averages.
Should I profile AI and pathing separately from spawning
Yes. Separate them in markers and test toggles. If you cannot isolate systems, you cannot prioritize fixes correctly.
How often should we re-run wave profiling
At least once per milestone and after major AI/content pipeline changes. Spawn regressions often reappear through unrelated feature work.
Conclusion
CPU spike debugging gets dramatically easier when you stop treating it like a mystery and treat it like a controlled experiment. A deterministic route, clear wave markers, and A/B capture discipline will save you from placebo optimizations and late-night guesswork.
If this helped, bookmark it for your next combat pass and share it with the teammate who owns spawn systems or performance triage.