performance-regression-debugging
关于
This skill helps developers identify and debug performance regressions caused by code changes. It provides instructions for comparing metrics and using profiling to locate the source of degradation and restore baseline performance. Use it when deployments cause slowdowns, metrics trend negatively, or users report slowness.
快速安装
Claude Code
推荐npx skills add aj-geddes/useful-ai-prompts/plugin add https://github.com/aj-geddes/useful-ai-promptsgit clone https://github.com/aj-geddes/useful-ai-prompts.git ~/.claude/skills/performance-regression-debugging在 Claude Code 中复制并粘贴此命令以安装该技能
技能文档
Performance Regression Debugging
Overview
Performance regressions occur when code changes degrade application performance. Detection and quick resolution are critical.
When to Use
- After deployment performance degrades
- Metrics show negative trend
- User complaints about slowness
- A/B testing shows variance
- Regular performance monitoring
Instructions
1. Detection & Measurement
// Before: 500ms response time
// After: 1000ms response time (2x slower = regression)
// Capture baseline metrics
const baseline = {
responseTime: 500, // ms
timeToInteractive: 2000, // ms
largestContentfulPaint: 1500, // ms
memoryUsage: 50, // MB
bundleSize: 150 // KB gzipped
};
// Monitor after change
const current = {
responseTime: 1000,
timeToInteractive: 4000,
largestContentfulPaint: 3000,
memoryUsage: 150,
bundleSize: 200
};
// Calculate regression
const regressions = {};
for (let metric in baseline) {
const change = (current[metric] - baseline[metric]) / baseline[metric];
if (change > 0.1) { // >10% degradation
regressions[metric] = {
baseline: baseline[metric],
current: current[metric],
percentChange: (change * 100).toFixed(1) + '%',
severity: change > 0.5 ? 'Critical' : 'High'
};
}
}
// Results:
// responseTime: 500ms → 1000ms (100% slower = CRITICAL)
// largestContentfulPaint: 1500ms → 3000ms (100% slower = CRITICAL)
2. Root Cause Identification
Systematic Search:
Step 1: Identify Changed Code
- Check git commits between versions
- Review code review comments
- Identify risky changes
- Prioritize by likelyhood
Step 2: Binary Search (Bisect)
- Start with suspected change
- Disable the change
- Re-measure performance
- If improves → this is the issue
- If not → disable other changes
git bisect start
git bisect bad HEAD
git bisect good v1.0.0
# Test each commit
Step 3: Profile the Change
- Run profiler on old vs new code
- Compare flame graphs
- Identify expensive functions
- Check allocation patterns
Step 4: Analyze Impact
- Code review the change
- Understand what changed
- Check for O(n²) algorithms
- Look for new database queries
- Check for missing indexes
---
Common Regressions:
N+1 Query:
Before: 1 query (10ms)
After: 1000 queries (1000ms)
Caused: Removed JOIN, now looping
Fix: Restore JOIN or use eager loading
Missing Index:
Before: Index Scan (10ms)
After: Seq Scan (500ms)
Caused: New filter column, no index
Fix: Add index
Memory Leak:
Before: 50MB memory
After: 500MB after 1 hour
Caused: Listener not removed, cache grows
Fix: Clean up properly
Bundle Size:
Before: 150KB gzipped
After: 250KB gzipped
Caused: Added library without tree-shaking
Fix: Use lighter alternative or split
Algorithm Efficiency:
Before: O(n) = 1ms for 1000 items
After: O(n²) = 1000ms for 1000 items
Caused: Nested loops added
Fix: Use better algorithm
3. Fixing & Verification
Fix Process:
1. Understand the Problem
- Profile and identify exactly what's slow
- Measure impact quantitatively
- Understand root cause
2. Implement Fix
- Make minimal changes
- Don't introduce new issues
- Test locally first
- Measure improvement
3. Verify Fix
- Run same measurement
- Check regression gone
- Ensure no new issues
- Compare metrics
Before regression: 500ms
After regression: 1000ms
After fix: 550ms (acceptable, minor overhead)
4. Prevent Recurrence
- Add performance test
- Set performance budget
- Alert on regressions
- Code review for perf
4. Prevention Measures
Performance Testing:
Baseline Testing:
- Establish baseline metrics
- Record for each release
- Track trends over time
- Alert on degradation
Load Testing:
- Test with realistic load
- Measure under stress
- Identify bottlenecks
- Catch regressions
Performance Budgets:
- Set max bundle size
- Set max response time
- Set max LCP/FCP
- Enforce in CI/CD
Monitoring:
- Track real user metrics
- Alert on degradation
- Compare releases
- Analyze trends
---
Checklist:
[ ] Baseline metrics established
[ ] Regression detected and measured
[ ] Changed code identified
[ ] Root cause found (code, data, infra)
[ ] Fix implemented
[ ] Fix verified
[ ] No new issues introduced
[ ] Performance test added
[ ] Budget set
[ ] Monitoring updated
[ ] Team notified
[ ] Prevention measures in place
Key Points
- Establish baseline metrics for comparison
- Use binary search to find culprit commits
- Profile to identify exact bottleneck
- Measure before/after fix
- Add performance regression tests
- Set and enforce performance budgets
- Monitor production metrics
- Alert on significant degradation
- Document root cause
- Prevent through code review
GitHub 仓库
相关推荐技能
polymarket
元这个Claude Skill为开发者提供完整的Polymarket预测市场开发支持,涵盖API调用、交易执行和市场数据分析。关键特性包括实时WebSocket数据流,可监控实时交易、订单和市场动态。开发者可用它构建预测市场应用、实施交易策略并集成实时市场预测功能。
creating-opencode-plugins
元该Skill帮助开发者创建OpenCode插件,用于接入命令、文件、LSP等25+种事件。它提供了插件结构、事件API规范和JavaScript/TypeScript实现模式,适合需要拦截操作、扩展功能或自定义事件处理的场景。开发者可通过它快速构建响应式模块来增强OpenCode AI助手的能力。
evaluating-llms-harness
测试该Skill通过60+个学术基准测试(如MMLU、GSM8K等)评估大语言模型质量,适用于模型对比、学术研究及训练进度追踪。它支持HuggingFace、vLLM和API接口,被EleutherAI等行业领先机构广泛采用。开发者可通过简单命令行快速对模型进行多任务批量评估。
cloudflare-turnstile
元这个Skill提供完整的Cloudflare Turnstile集成知识,用于在表单、登录页面和API端点中实现无验证码的机器人防护。它支持React/Next.js/Hono等框架集成,涵盖令牌验证、错误代码调试和端到端测试等场景。通过运行后台不可见挑战,在保持用户体验的同时有效阻止自动化流量和垃圾信息。
