Stabilized Crashed Unity Build Server

Jenkins Unity Editor CI/CD CPU Optimization Trade-off Engineering

Context: Unity CI/CD server stability crisis at VARLab (June 2024)

Problem: VM crashes when 2-3 pipelines run simultaneously due to Unity Editor's 100% CPU usage

Solution: Trade-off approach — shared project files + optimization skip

Result: Server stabilized, concurrent pipelines supported

Byproduct: 80% faster builds, 90% CPU reduction

Build Server Stabilization Infographic
80%
Faster Builds
90%
CPU Reduction
0
Crashes
Safe
Concurrent Pipelines

The Crisis

Symptom: CI/CD VM becomes extremely slow or shuts down when 2-3 PR pipelines run simultaneously.

Key Insight: Unity Editor provides no CPU throttling option. It consumes all available resources.

Root Cause Analysis:

ProcessCPU ImpactBuild Time
Unity Editor initial compile (30,000+ files)100%~10 min
wasm-opt.exe (WebAssembly optimization)50-100%2-3 min
IL2CPP.exe (C# to Wasm conversion)70-90%1-2 sec

Build time varies by project size and machine resources. CPU always consumes all available resources.


Solution: Trade-off Approach

1. Single Project Files for All Branches

Before

Each branch creates new folder → git clone → Unity initial compile (10 min)

After

All branches share single project folder → skip initial compile

StageBeforeAfter
EditMode Test~10 min< 1 min
Build Project~10 min1-5 min

Validation: Tested with 7 branches — no errors switching between branches.

JIRA Ticket (PDF)

2. WebAssembly Optimization Level = 0

Before

wasm-opt.exe runs at 50-100% CPU for 2-3 minutes during CI builds

After

Set optimization level to 0 for CI pipeline (CD keeps optimization)

MetricBeforeAfter
Peak CPU (wasm-opt.exe)50-100%0% (skipped)
Sustained CPU70-90%10-20%

Rationale: CI pipeline only needs to verify build success/failure, not produce optimized artifacts.

Pull Request (PDF) Build Time Reduction Analysis (PDF)

Trade-off Accepted

This solution violates CI/CD best practice of "clean builds from scratch":

Why this was acceptable:


Timeline (Git Commits)

DateCommitDescription
Jun 13, 202433b5dafSingle project files for all branches
Jun 19, 2024daa5216More RAM, less CPU memory setting
Jun 24, 202451d4d74Test with enhanced setting (less CPU, more RAM)
Jun 24, 2024d4c9807More memory for il2cpp.exe and wasm-opt.exe
Jun 25, 2024a35e944Original CPU usage setting
Jun 25, 2024f619a90emscripten compiler optimization low setting
Jun 26, 2024909d0dbReduce CPU Usage on CI Pipeline