Analyze performance bottlenecks and create an optimization plan
Analyzes performance bottlenecks and creates a comprehensive optimization plan for codebases.
/plugin marketplace add dgriffith/bad-daves-robot-army/plugin install dgriffith-bad-daves-robot-army@dgriffith/bad-daves-robot-armyUsing @agent-performance-optimizer prepare a performance review report. You must analyze performance bottlenecks and optimization opportunities in the codebase and create a comprehensive plan WITHOUT making any changes.
The user invoked: /perf-review {optional_scope}
Valid scopes:
git status and git diff)git log and git diff)gh pr view and gh pr diff)If scope is "current changes":
git status to identify changed filesgit diff to see uncommitted changesIf scope is "recent changes":
git log --oneline -10 to see recent commitsgit diff HEAD~5..HEAD or appropriate rangeIf scope starts with "PR":
gh pr view {number} to get PR detailsgh pr diff {number} to get the changesIf scope is a path:
If no scope provided:
Performance Analysis
Resource Usage Review
Scalability Assessment
Create a markdown file at /reports/performance-review-{timestamp}.md with:
# Performance Review Plan
Generated: {timestamp}
Scope: {full_path_or_entire_project}
## Executive Summary
Brief overview of performance state and critical findings
## Performance Bottlenecks
### Critical Issues (Severe Impact)
- [ ] Algorithm X: O(n²) complexity in hot path
- [ ] Memory leak: In component Y
- [ ] Blocking I/O: In service Z
### High Priority Issues
- [ ] Inefficient query: In function A
- [ ] Missing cache: For operation B
- [ ] Redundant computation: In loop C
### Medium Priority Issues
- [ ] Suboptimal data structure: In module D
- [ ] Unnecessary allocations: In method E
## Performance Metrics
### Current State
- Average response time: X ms
- Memory usage: Y MB
- CPU utilization: Z%
- Key bottlenecks: List
### Target State
- Response time: < X ms
- Memory usage: < Y MB
- CPU utilization: < Z%
## Optimization Plan
### Quick Wins (1-3 days)
1. Add caching for X
2. Optimize query Y
3. Remove redundant computation Z
### Major Optimizations (1-2 weeks)
1. Refactor algorithm A to O(n log n)
2. Implement connection pooling
3. Add batch processing for B
### Architectural Changes (2-4 weeks)
1. Introduce async processing
2. Implement data partitioning
3. Add load balancing
## Implementation Strategy
### Phase 1: Low-hanging Fruit
- Cache frequently accessed data
- Optimize database queries
- Remove obvious inefficiencies
### Phase 2: Algorithm Improvements
- Replace inefficient algorithms
- Optimize data structures
- Implement better search strategies
### Phase 3: System-level Changes
- Add horizontal scaling
- Implement caching layer
- Optimize resource usage
## Performance Testing Plan
- Benchmark current performance
- Set performance targets
- Create performance test suite
- Monitor improvements
## Risk Assessment
### Safe Optimizations
- Adding caches
- Query optimization
- Code cleanup
### Moderate Risk
- Algorithm changes
- Data structure modifications
### High Risk
- Architectural changes
- Async refactoring
## Recommendations
- Performance monitoring tools
- Profiling approach
- Continuous performance testing
## Estimated Impact
- Quick wins: 20-30% improvement
- Major optimizations: 40-60% improvement
- Full plan: 70-80% improvement
## Effort Estimate
- Quick wins: X hours
- Major optimizations: Y days
- Complete plan: Z weeks
YOU MUST CREATE THE REPORT FILE. This is not optional.
Create the report file using the Write tool at the specified path:
/reports/{command-name}-{scope}-{timestamp}.mdYYYY-MM-DD-HHmmss/reports/architecture-review-entire-project-2025-10-14-143022.mdFill in ALL sections of the report template
Confirm completion by telling the user:
❌ DON'T: Just summarize findings in the chat ❌ DON'T: Say "I'll create a report" without actually doing it ❌ DON'T: Leave sections incomplete or with placeholders ❌ DON'T: Forget to use the Write tool
✅ DO: Always use the Write tool to create the markdown file ✅ DO: Fill in every section with real findings ✅ DO: Provide the full path to the user when done ✅ DO: Include actionable recommendations
Before responding to the user, verify:
Remember: The report is the primary deliverable. The chat summary is secondary.