[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-692630ce-cc69-4f16-8116-36b2e30c18b0":3,"$flwmPQ36OyQ6ZYMXQRCQs7aRidh-3GnuO7FWj69Wvuro":42},{"id":4,"title":5,"description":6,"categoryId":7,"moduleId":8,"tags":9,"prompt":10,"icon":11,"source":12,"sourceUrl":13,"authorId":14,"authorName":15,"isPublic":16,"stars":17,"runs":18,"createdAt":19,"updatedAt":19,"module":20,"category":27,"packages":33},"692630ce-cc69-4f16-8116-36b2e30c18b0","performance-profiler","针对Node.js、Python和Go应用程序的系统性能分析。识别CPU、内存和I\u002FO瓶颈，生成火焰图，分析包大小，优化数据库查询，使用k6和Artillery进行负载测试。始终在前后进行测量。在调查慢速端点、规划性能预算或在生产中寻找内存泄漏时使用。","cat_coding_backend","mod_coding","alirezarezvani,coding","---\nname: \"performance-profiler\"\ndescription: \"Systematic performance profiling for Node.js, Python, and Go applications. Identifies CPU, memory, and I\u002FO bottlenecks, generates flamegraphs, analyzes bundle sizes, optimizes database queries, runs load tests with k6 and Artillery. Always measures before and after. Use when investigating a slow endpoint, planning a performance budget, or hunting a memory leak in production.\"\n---\n\n# Performance Profiler\n\n**Tier:** POWERFUL  \n**Category:** Engineering  \n**Domain:** Performance Engineering  \n\n---\n\n## Overview\n\nSystematic performance profiling for Node.js, Python, and Go applications. Identifies CPU, memory, and I\u002FO bottlenecks; generates flamegraphs; analyzes bundle sizes; optimizes database queries; detects memory leaks; and runs load tests with k6 and Artillery. Always measures before and after.\n\n## Core Capabilities\n\n- **CPU profiling** — flamegraphs for Node.js, py-spy for Python, pprof for Go\n- **Memory profiling** — heap snapshots, leak detection, GC pressure\n- **Bundle analysis** — webpack-bundle-analyzer, Next.js bundle analyzer\n- **Database optimization** — EXPLAIN ANALYZE, slow query log, N+1 detection\n- **Load testing** — k6 scripts, Artillery scenarios, ramp-up patterns\n- **Before\u002Fafter measurement** — establish baseline, profile, optimize, verify\n\n---\n\n## When to Use\n\n- App is slow and you don't know where the bottleneck is\n- P99 latency exceeds SLA before a release\n- Memory usage grows over time (suspected leak)\n- Bundle size increased after adding dependencies\n- Preparing for a traffic spike (load test before launch)\n- Database queries taking >100ms\n\n---\n\n## Quick Start\n\n```bash\n# Analyze a project for performance risk indicators\npython3 scripts\u002Fperformance_profiler.py \u002Fpath\u002Fto\u002Fproject\n\n# JSON output for CI integration\npython3 scripts\u002Fperformance_profiler.py \u002Fpath\u002Fto\u002Fproject --json\n\n# Custom large-file threshold\npython3 scripts\u002Fperformance_profiler.py \u002Fpath\u002Fto\u002Fproject --large-file-threshold-kb 256\n```\n\n---\n\n## Golden Rule: Measure First\n\n```bash\n# Establish baseline BEFORE any optimization\n# Record: P50, P95, P99 latency | RPS | error rate | memory usage\n\n# Wrong: \"I think the N+1 query is slow, let me fix it\"\n# Right: Profile → confirm bottleneck → fix → measure again → verify improvement\n```\n\n---\n\n## Node.js Profiling\n→ See references\u002Fprofiling-recipes.md for details\n\n## Before\u002FAfter Measurement Template\n\n```markdown\n## Performance Optimization: [What You Fixed]\n\n**Date:** 2026-03-01  \n**Engineer:** @username  \n**Ticket:** PROJ-123  \n\n### Problem\n[1-2 sentences: what was slow, how was it observed]\n\n### Root Cause\n[What the profiler revealed]\n\n### Baseline (Before)\n| Metric | Value |\n|--------|-------|\n| P50 latency | 480ms |\n| P95 latency | 1,240ms |\n| P99 latency | 3,100ms |\n| RPS @ 50 VUs | 42 |\n| Error rate | 0.8% |\n| DB queries\u002Freq | 23 (N+1) |\n\nProfiler evidence: [link to flamegraph or screenshot]\n\n### Fix Applied\n[What changed — code diff or description]\n\n### After\n| Metric | Before | After | Delta |\n|--------|--------|-------|-------|\n| P50 latency | 480ms | 48ms | -90% |\n| P95 latency | 1,240ms | 120ms | -90% |\n| P99 latency | 3,100ms | 280ms | -91% |\n| RPS @ 50 VUs | 42 | 380 | +804% |\n| Error rate | 0.8% | 0% | -100% |\n| DB queries\u002Freq | 23 | 1 | -96% |\n\n### Verification\nLoad test run: [link to k6 output]\n```\n\n---\n\n## Optimization Checklist\n\n### Quick wins (check these first)\n\n```\nDatabase\n□ Missing indexes on WHERE\u002FORDER BY columns\n□ N+1 queries (check query count per request)\n□ Loading all columns when only 2-3 needed (SELECT *)\n□ No LIMIT on unbounded queries\n□ Missing connection pool (creating new connection per request)\n\nNode.js\n□ Sync I\u002FO (fs.readFileSync) in hot path\n□ JSON.parse\u002Fstringify of large objects in hot loop\n□ Missing caching for expensive computations\n□ No compression (gzip\u002Fbrotli) on responses\n□ Dependencies loaded in request handler (move to module level)\n\nBundle\n□ Moment.js → dayjs\u002Fdate-fns\n□ Lodash (full) → lodash\u002Ffunction imports\n□ Static imports of heavy components → dynamic imports\n□ Images not optimized \u002F not using next\u002Fimage\n□ No code splitting on routes\n\nAPI\n□ No pagination on list endpoints\n□ No response caching (Cache-Control headers)\n□ Serial awaits that could be parallel (Promise.all)\n□ Fetching related data in a loop instead of JOIN\n```\n\n---\n\n## Common Pitfalls\n\n- **Optimizing without measuring** — you'll optimize the wrong thing\n- **Testing in development** — profile against production-like data volumes\n- **Ignoring P99** — P50 can look fine while P99 is catastrophic\n- **Premature optimization** — fix correctness first, then performance\n- **Not re-measuring** — always verify the fix actually improved things\n- **Load testing production** — use staging with production-size data\n\n---\n\n## Best Practices\n\n1. **Baseline first, always** — record metrics before touching anything\n2. **One change at a time** — isolate the variable to confirm causation\n3. **Profile with realistic data** — 10 rows in dev, millions in prod — different bottlenecks\n4. **Set performance budgets** — `p(95) \u003C 200ms` in CI thresholds with k6\n5. **Monitor continuously** — add Datadog\u002FPrometheus metrics for key paths\n6. **Cache invalidation strategy** — cache aggressively, invalidate precisely\n7. **Document the win** — before\u002Fafter in the PR description motivates the team\n","","imported","https:\u002F\u002Fgithub.com\u002Falirezarezvani\u002Fclaude-skills","user_system_seed","SkillOPIC",true,163,1188,"2026-05-16 13:54:48",{"id":8,"name":21,"slug":22,"icon":23,"description":24,"sort":25,"createdAt":26},"编程开发","coding","mdi-code-braces","代码生成、调试、审查，提升开发效率",2,"2026-05-16 12:53:40",{"id":7,"name":28,"slug":29,"icon":30,"description":31,"moduleId":8,"sort":25,"skillCount":32,"createdAt":26},"后端开发","backend","mdi-server","API、数据库、服务端架构",296,[34],{"id":35,"skillId":4,"version":36,"fileName":37,"fileSize":38,"filePath":39,"fileHash":40,"manifest":41,"createdAt":19},"cf77b3a1-53b2-4bc7-98f3-afa00a2daeec","1.0.0","performance-profiler.zip",9797,"uploads\u002Fskills\u002F692630ce-cc69-4f16-8116-36b2e30c18b0\u002Fperformance-profiler.zip","9cbf27aead7f57b58847734ea0bf418a323533884afaef0f9d572ad88cdf9fc7","[{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":5435},{\"path\":\"references\u002Fprofiling-recipes.md\",\"isDirectory\":false,\"size\":11531},{\"path\":\"scripts\u002Fperformance_profiler.py\",\"isDirectory\":false,\"size\":6137}]",{"code":43,"message":44,"data":45},200,"success",{"items":46,"stats":47,"page":50},[],{"averageRating":48,"totalRatings":48,"ratingCounts":49},0,[48,48,48,48,48],{"limit":51,"offset":48,"hasMore":52,"nextOffset":51,"ratedOnly":16},15,false]