Profiling Builds¶
Analyze build performance to identify bottlenecks.
Chrome Trace¶
Generate Trace¶
View Trace¶
- Open Chrome
- Navigate to
chrome://tracing - Load
build_trace.json
What to Look For¶
- Long bars: Slow build steps
- Gaps: Scheduling inefficiency
- Serialization: Sequential dependencies
Build Statistics¶
Shows:
- Total build time
- Commands executed
- Cache statistics
Explain Mode¶
Shows why targets are rebuilding.
Cache Analysis¶
Low hit rate? Check:
- Undeclared dependencies
- Non-deterministic builds
- Environment differences
Example Analysis¶
# 1. Generate trace
rninja --trace trace.json
# 2. Check stats
rninja -d stats
# 3. Check cache
rninja -t cache-stats
# 4. Investigate rebuilds
rninja -d explain
Common Issues¶
| Issue | Symptom | Solution |
|---|---|---|
| Sequential builds | Gaps in trace | Add parallelism |
| Low cache hits | Rebuilding cached | Check deps |
| Slow no-op | > 100ms startup | Use daemon |