| name | performance-profiling |
| description | Performance profiling principles. Measurement, analysis, and optimization techniques. |
| allowed-tools | Read, Glob, Grep, Bash |
Performance Profiling
Measure, analyze, optimize.
Core Web Vitals
- LCP (Load): < 2.5s
- INP (Interactive): < 200ms
- CLS (Stability): < 0.1
Profiling Workflow
- BASELINE: Measure first.
- IDENTIFY: Find bottleneck (Lighthouse, Bundle Analyzer, DevTools).
- FIX: Targeted change.
- VALIDATE: Confirm improvement.
Analysis
- Bundle: Split large deps, dedupe, tree shake.
- Runtime: Long tasks (>50ms) block UI.
- Memory: Growing heap = leak.
Quick Wins
- Compression (Gzip/Brotli).
- Lazy Load Images.
- Code Split Routes.
- Cache Static Assets.
🧠 Aletheia Reasoning Protocol (Optimization)
1. Generator (Hypothesis)
- Suspect: "DB query slow?".
- Tool: "
explain analyze".
- Target: "Reduce p99 by 50ms".
2. Verifier (Measurement)
- Baseline: "Record metric BEFORE fix".
- Isolation: "Network or CPU?".
- Significance: "Is 1ms worth complexity?".
3. Reviser (Stabilization)
- Regression: "Add test to prevent regression".
- Cache: "Can't fix? Cache it.".
🛡️ Security & Safety Protocol (Profiling)
- Timing Attacks: No optimizations on auth checks.
- Info Leak: Don't publish profiles (PII/Env vars).
- Prod Impact: Don't crash prod with profiler overhead.
- Sampling: Use sampling on high traffic.