/goal Audit this project for actionable performance, resource-management, and concurrency problems. Identify unnecessary work, poor scaling, resource retention, and lifecycle errors that affect meaningful user or system workflows. Validate findings with reproducible evidence and rank them by expected repair ROI.
Do not assume a particular language, framework, architecture, or application type. Adapt the investigation to the repository.
## 1. Discover the system
Read the repository's instructions and identify:
- Its purpose, architecture, execution environments, and supported platforms.
- Critical user journeys or system operations.
- Entry points, data flows, persistence boundaries, background jobs, and external dependencies.
- Existing tests, benchmarks, profiling tools, and observability.
- Representative workload sizes and any documented performance requirements.
Record the reviewed revision, working tree state, and environment.
Select a bounded set of important workflows based on impact and likely risk. Explain the selection. Review the current implementation, not only recent changes.
## 2. Investigate how work and resources scale
Trace selected workflows end to end. Look for patterns such as:
- Small or bounded requests triggering full scans, large materialization, or complete recomputation.
- Repeated queries, network calls, serialization, parsing, rendering, or filesystem operations.
- N+1 access patterns, quadratic algorithms, repeated collection copies, and redundant dependency resolution.
- Blocking work on latency-sensitive threads or event loops.
- Excessive startup work, eager initialization, and avoidable work on frequently executed paths.
- Missing backpressure, excessive concurrency, retry amplification, and unbounded queues.
- Caches whose memory grows without an effective total budget, invalidation policy, or eviction strategy.
- Leaked or unnecessarily retained subscriptions, listeners, timers, handles, connections, tasks, and subprocesses.
- Timeouts that do not cancel underlying work, abandoned requests that keep running, and asynchronous work that outlives its owner.
- Lock contention, overly broad serialization, races, stale writes, and inconsistent read-modify-write operations.
- Polling, watchers, refresh loops, or invalidation chains that amplify small changes into large amounts of work.
For each path, ask:
“What determines its cost: request size, total stored data, elapsed uptime, concurrency, or unrelated system activity?”
Treat suspicious patterns as hypotheses. A pattern alone is not a defect.
## 3. Validate promising hypotheses
For each candidate:
1. Identify a realistic trigger and the expected behavior or resource bound.
2. Inspect callers, guards, caching, cancellation, and cleanup before drawing conclusions.
3. Create the smallest reproducible experiment using the actual implementation.
4. Prefer realistic local dependencies and isolated fixtures over mocks.
5. Use controlled stubs only where necessary, and state exactly what they replace.
6. Vary input size, accumulated state, or concurrency to establish scaling.
7. Measure the relevant quantities: operation counts, rows, bytes, allocations, retained resources, CPU, elapsed time, latency distribution, or throughput.
8. Include controls and repeated samples where meaningful.
9. Separate instrumentation overhead, warm-up, caching, and environmental noise from application cost.
Do not equate high resource usage with waste without understanding its purpose. Do not present synthetic benchmark timing as observed production latency.
Run focused existing tests and appropriate profiling tools. Avoid broad test runs unless they answer a concrete question.
Investigate failures instead of repeatedly rerunning until green. Distinguish product defects, cascading failures, test isolation problems, and environment limitations.
## 4. Exercise the real interface
Where feasible, validate the affected workflow through the project's actual interface: application UI, CLI, API, worker, service, library consumer, or batch job.
Confirm which build and configuration are running.
Keep these evidence levels distinct:
- Static code analysis.
- Isolated implementation probes.
- Integration tests.
- Real interface or system workflows.
- Production observations, if available and authorized.
If access, credentials, tooling, or infrastructure blocks validation, continue independent work and document the exact limitation. Never substitute a fixture or mock and describe it as end-to-end validation.
## 5. Rank actionable findings
For each confirmed finding, provide:
- Severity and confidence.
- Exact source locations.
- Triggering conditions and affected workflows.
- Expected versus observed behavior.
- Reproduction steps and raw evidence.
- Scaling behavior and practical impact.
- A minimal repair direction.
- Regression acceptance criteria.
- Remaining uncertainty.
Rank repair ROI using:
- Impact on users or system reliability.
- Likely frequency and affected population.
- Strength of evidence.
- Expected implementation effort.
- Regression and operational risk.
Label unknown frequency and repair cost as estimates. Avoid false numerical precision.
Prefer removing unnecessary work over weakening guarantees. Do not automatically recommend more caching, batching, concurrency, lower limits, or broader architectural changes.
## 6. Boundaries and completion
Follow repository-specific instructions. Keep tracked product code unchanged unless fixes are explicitly requested. Temporary probes, isolated fixtures, profiles, and reports are allowed.
Do not modify real user data, disrupt unrelated processes, use production systems without authorization, or publish sensitive evidence.
Deliver:
- An executive summary and prioritized findings.
- A workflow coverage matrix.
- Reproduction artifacts and measurements.
- Rejected hypotheses.
- Unresolved risks and validation blockers.
Finish when the selected workflows have been investigated or have explicit blockers, every confirmed finding has a defensible evidence chain, and the report is ready for review.
Do not stop at a list of suspicious code patterns. Do not invent findings to meet a quota. Do not claim to have found every possible problem.