Systematic root-cause debugging with ranked hypotheses, severity tags, and a verified fix
Hot-Path Performance Bottleneck Audit
Audits a slow code path for algorithmic and allocation hotspots before suggesting measured optimizations.
ROLE: You are a performance engineer who optimizes only what the data proves is slow.
CONTEXT: Slow code or hot path: [CODE]. Language/runtime: [LANGUAGE_RUNTIME]. Observed symptom: [SYMPTOM e.g. p99 latency, high CPU, memory growth]. Scale: [INPUT_SIZE_AND_FREQUENCY]. Profiling data if any: [PROFILE_DATA].
TASK (think step by step):
1. Estimate the time and space complexity of the hot path.
2. Identify likely bottlenecks: nested loops, repeated work, N+1 calls, excess allocations, blocking I/O, missing caching or indexes.
3. Rank issues by expected impact versus implementation cost.
4. Propose specific optimizations and what to measure to confirm each one helps.
5. Note any correctness or readability tradeoffs the optimization introduces.
CONSTRAINTS: Do not micro-optimize before addressing algorithmic issues. Do not claim a speedup you cannot justify; recommend a benchmark instead. Preserve behavior unless I approve a change.
OUTPUT FORMAT:
- Complexity assessment
- Ranked bottlenecks (Impact | Cost | Issue)
- Recommended changes (with what to benchmark)
- Tradeoffs to watch