Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Here’s a clean, senior-level README you can drop directly into GitHub. It’s structured, sharp, and evidence-driven — not bloated.


🚀 Unity Performance Study — Update Strategies at Scale

A controlled Unity performance benchmark comparing how different update architectures scale under identical high-load conditions (up to 10,000 entities + active bullets).

This study isolates the cost of:

  • MonoBehaviour per-object Update()
  • Centralized manager updates
  • ECS (Data-Oriented Design)

🎯 Goal

Measure how update strategy impacts:

  • CPU frame time
  • Script execution cost
  • GC allocations
  • Frame stability
  • Scalability limits

All variants run the same scene, same visuals, same behavior — only the update architecture changes.


🧪 Test Setup

  • 10,000 enemies (red capsules)
  • ~1,000–1,500 active bullets (yellow spheres)
  • Continuous firing system
  • Deterministic grid + shooting pattern
  • Direct Instantiate / Destroy (no pooling)
  • Same camera, materials, physics, and logic

🧱 Variants

A — Lifecycle Control

  • Minimal Update() usage
  • Passive enemies
  • Only bullets update
  • Baseline for lifecycle + rendering cost

B — Per-Object Update

  • 10,000 enemy Update() calls
  • ~1,500 bullet Update() calls
  • Classic MonoBehaviour scaling

👉 Bottleneck: Script execution (Update dispatch)


C — Central Manager

  • No per-object Update()
  • One manager updates all enemies + bullets
  • Same GameObjects and visuals

👉 Bottleneck: Transform iteration / memory access


D — ECS (Entities)

  • Enemies and bullets as entities
  • Systems handle movement, lifetime, destruction
  • Chunk-based iteration

👉 Bottleneck shifts away from scripting entirely


📊 Results (10,000 Entities)

Variant Frame Time Script Cost Update Calls Bottleneck
A ~22–30 ms ~0.5 ms minimal Render / Scene
B ~40 ms ~8.6 ms 10,000+ Scripts
C ~32 ms ~4.3 ms 1 manager Transform iteration
D ~9.4 ms ~0.01 ms ECS systems Rendering

🔍 Key Insights

1. Per-object Update does not scale

Even trivial logic becomes expensive when executed 10,000 times per frame.


2. Manager pattern reduces overhead

Centralized updates remove engine → script dispatch cost, improving CPU time significantly.


3. Transform cost still exists

Even without Update(), iterating and writing 10,000 transforms is still expensive.


4. ECS changes the scaling model

ECS removes per-object overhead and processes data in chunks, leading to:

  • Lower CPU cost
  • Better cache locality
  • Stable frame times at scale

🧠 Conclusion

At scale, performance is dominated not by logic complexity, but by how often and how it is executed.

  • MonoBehaviour → high dispatch overhead
  • Manager → reduced dispatch, same data cost
  • ECS → data-oriented iteration, best scalability

📸 Evidence

Each variant includes:

  • HUD (live stats)
  • CPU Timeline
  • CPU Hierarchy
  • ECS system breakdown (for Variant D)

🛠️ Project Structure

A/  → Lifecycle Control
B/  → Per-Object Update
C/  → Manager Update
D/  → ECS Implementation

Each contains:

  • HUD screenshot
  • Profiler Timeline
  • Profiler Hierarchy

▶️ How to Run

  1. Open project in Unity

  2. Load any variant scene (A / B / C / D)

  3. Press Play

  4. Use HUD:

    • Enable Manual Count or Ramp Mode
    • Adjust Enemy Count
    • Adjust Fire Rate
  5. Observe performance + profiler


⚠️ Important Constraints

This study intentionally avoids:

  • Object pooling
  • GPU optimizations
  • Complex AI or animation
  • Visual effects
  • Randomization

Reason: isolate update architecture only


📌 Takeaway

If you're building large-scale systems in Unity:

  • Avoid per-object Update() at scale
  • Prefer centralized logic for medium complexity
  • Use ECS for high-entity simulations

🔥 Why this matters

This is not a synthetic benchmark.

It represents real-world patterns:

  • Bullet systems
  • Enemy swarms
  • Simulation-heavy gameplay

Understanding these trade-offs directly impacts:

  • Frame stability
  • Device compatibility
  • Scalability limits

👤 Author

James De Raja
Senior Real-Time Performance Engineer
Unity Rendering | Frame Pacing | XR Optimization
Portfolio | LinkedIn


License

MIT (for experimental code only)

About

Unity performance study comparing MonoBehaviour, manager, and ECS update patterns at 10,000+ entities under identical conditions.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages