performance
Optimize application performance through async patterns, caching strategies, profiling, and resource management. Use when diagnosing slow endpoints, implementing caching layers, profiling CPU/memory b
Files4
View on GitHubSKILL.md.claude/skills/performance/SKILL.md
GitHubPerformance
Purpose: Optimize application speed, throughput, and resource usage for production loads. Strategy: Profile first, optimize bottlenecks, measure impact. Note: For language-specific implementations, see C# Development or Python Development.
When to Use This Skill
- Diagnosing slow application endpoints
- Implementing caching strategies
- Profiling CPU or memory bottlenecks
- Optimizing database query performance
- Setting up performance monitoring and alerting
Prerequisites
- Application running in a profiling-capable environment
- Access to monitoring tools
Decision Tree
Performance concern?
+- Not yet measured? -> Profile FIRST (don't guess)
| +- .NET -> dotnet-trace / BenchmarkDotNet
| +- Python -> cProfile / py-spy
| - Node.js -> clinic.js / --prof
+- Slow API response?
| +- Database query? -> EXPLAIN ANALYZE -> add index
| +- External service? -> Add caching + async calls
| - Computation? -> Optimize algorithm or add memoization
+- High memory usage?
| +- Large collections? -> Stream/paginate instead of loading all
| - Memory leaks? -> Profile allocations, check dispose patterns
+- Concurrency bottleneck?
| +- I/O bound? -> async/await (don't block threads)
| - CPU bound? -> Parallel processing / background workers
- Quick wins? -> See Quick Wins table below
Quick Wins
| Optimization | Impact | Effort |
|---|---|---|
| Enable Response Compression | 70-90% size reduction | Low |
| Add Database Indexes | 10-100x query speed | Low |
| Implement Caching | 50-99% latency reduction | Medium |
| Use Async I/O | 5-10x throughput | Medium |
| Fix N+1 Queries | 10-1000x DB performance | Medium |
Performance Anti-Patterns
| Anti-Pattern | Problem | Solution |
|---|---|---|
| Premature Optimization | Optimize before profiling | Profile first, optimize bottlenecks |
| Over-Caching | Cache everything | Cache strategically based on access patterns |
| Blocking I/O | Synchronous network calls | Use async/await |
| No Pagination | Load all results | Paginate large datasets |
| Missing Indexes | Full table scans | Add indexes on frequently queried columns |
| N+1 Queries | Loop over queries | Use JOINs or batch loading |
Optimization Checklist
Before Production:
- Profile application under realistic load
- Add database indexes on frequently queried columns
- Implement caching for expensive operations
- Enable response compression
- Fix N+1 query problems
- Use connection pooling
- Implement async I/O where applicable
- Paginate large result sets
- Set up monitoring and alerts
- Conduct load testing
- Set performance budgets
- Optimize static asset delivery
Resources
Profiling Tools:
- .NET: BenchmarkDotNet, dotTrace, PerfView
- Python: cProfile, py-spy, Scalene
- Node.js: clinic.js, 0x, Chrome DevTools
- Java: JProfiler, VisualVM
Load Testing:
- k6 - Modern load testing
- Apache JMeter - Industry standard
- Gatling - Scala-based testing
Guides:
See Also: Skills.md - AGENTS.md
Last Updated: January 27, 2026
Scripts
| Script | Purpose | Usage |
|---|---|---|
run-benchmark.ps1 |
Run benchmarks (.NET/Python/Node) with baseline comparison | ./scripts/run-benchmark.ps1 [-Baseline baseline.json] |
Troubleshooting
| Issue | Solution |
|---|---|
| Cache stampede on expiry | Use cache-aside with staggered TTL or background refresh |
| Memory leak in production | Profile with dotMemory/py-spy, check for unbounded collections |
| High latency spikes | Check GC pauses, database connection pool, and external service timeouts |