dragonked2 / optimization
Improve performance, latency, throughput, memory usage, or general efficiency by defining metrics, measuring, attributing bottlenecks, and prioritizing macro-optimizations.
0
SKILL.md1.5 KB
Optimization Skill
Systematic performance optimization workflow.
Process
- Define Metrics — identify what to measure (latency p50/p99, throughput, memory, CPU)
- Measure Baseline — capture current performance before any changes
- Profile — use profiling tools to find actual bottlenecks (don't guess)
- Attribute — map bottlenecks to specific code paths
- Prioritize — fix the highest-impact bottleneck first
- Optimize — apply targeted changes (algorithm, data structure, caching, concurrency, I/O)
- Verify — re-measure and confirm improvement
Rules
- Never optimize without a baseline measurement
- Never guess at bottlenecks — profile first
- One change at a time so impact is attributable
- Document before/after metrics for every optimization
- Prefer algorithmic improvements over micro-optimizations
- If optimization reduces readability, add a comment explaining why
Common Patterns
- Algorithmic: O(n^2) → O(n log n) or O(n)
- Caching: memoize expensive repeated computations
- Batching: combine many small operations into fewer large ones
- Lazy evaluation: defer work until result is actually needed
- Concurrency: parallelize independent work
- I/O: async, buffering,减少 system calls
- Memory: reduce allocations, reuse buffers, arena allocators