performance-profiling
Skill9 starsChanged 5 months agoApache-2.0View on GitHub
Diagnoses and fixes runtime performance problems — finds hotspots via profiling/measurement, then fixes N+1 queries, unnecessary allocations, blocking IO, and algorithmic complexity, proving the gain with before/after numbers. Use when something is measurably slow or resource-heavy.
16 other projects use a version of this.
Adopted by
Most recently taken up by
- nahid-sparktales/agent-dispatchertheir own version, first seen Sep 21, 2026
- VoDaiLocz/kilo-kit-mcptheir own version, first seen Aug 21, 2026
- arjunprabhulal/agent-skillstheir own version, first seen Aug 3, 2026
- rshankras/claude-code-apple-skillstheir own version, first seen Jul 16, 2026
- RadekCihlar/Claude-skillstheir own version, first seen Jul 10, 2026
- roanbrasil/engineer-grade-agent-skillstheir own version, first seen Jun 17, 2026
Used with
Projects with it also use intelligent-routing, behavioral-modes and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
tiendatworkSkillintelligent-routing
Automatic agent selection and intelligent task routing. Analyzes user requests and automatically selects the best specialist agent(s) without requiring explicit user mentions.
Also in 3 projects that use this
xfstudioSkillbehavioral-modes
AI operational modes (brainstorm, implement, debug, review, teach, ship, orchestrate). Use to adapt behavior based on task type.
Also in 3 projects that use this
xfstudioSkillred-team-tactics
Red team tactics principles based on MITRE ATT&CK. Attack phases, detection evasion, reporting.
Also in 3 projects that use this
benshapyroSkilldocumentation-templates
Generates README files, API documentation, and inline code comments following best practices. Use when creating project documentation, writing READMEs, documenting APIs, or explaining complex code.
Also in 3 projects that use this
- +8 more from xfstudio
Other versions16 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 16
- rshankras/claude-code-apple-skills★ 777same name
- conorluddy/xclaude-plugin★ 182same name
- HeshamFS/materials-simulation-skills★ 69same name
- nahid-sparktales/agent-dispatcher★ 59same name
- VoDaiLocz/kilo-kit-mcp★ 27same name
- xfstudio/skills★ 9same name
- roanbrasil/engineer-grade-agent-skills★ 8same name
- arjunprabhulal/agent-skills★ 4same name
- mehuldil/ai_sdlc_platform★ 4same name
- SKB3002/agenthub★ 4same name
6 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository147 other files it gives its agents.
- second-brain/AGENTS.mdAGENTS.md
- second-brain/CLAUDE.mdCLAUDE.md
- agent-tool-mcp-builderSkill
- api-design-reviewSkill
- async-concurrency-correctnessSkill
- audit-accessibility-wcagSkill
- audit-license-complianceSkill
- audit-technical-seoSkill
- auth-jwt-sessionSkill
- author-codemodSkill
- brainstorm-designSkill
- build-audit-loggingSkill
- build-cdc-streaming-pipelineSkill
- build-cli-toolSkill
- build-data-tableSkill
- build-etl-pipelineSkill
- build-form-validationSkill
- build-native-mobile-uiSkill
- build-office-docsSkill
- build-offline-first-syncSkill
- build-react-componentSkill
- build-realtime-channelSkill
- build-spreadsheetSkill
- build-vector-searchSkill
- caching-strategySkill
- cicd-pipeline-authorSkill
- cloud-cost-optimizeSkill
- code-commentsSkill
- code-reviewSkill
- compose-local-dev-stackSkill
- configure-bundler-buildSkill
- configure-dns-tlsSkill
- configure-reverse-proxy-lbSkill
- configure-security-headers-cspSkill
- contract-testingSkill
- datetime-timezone-correctnessSkill
- db-migration-safetySkill
- debug-ci-pipeline-failureSkill
- debug-flaky-testsSkill
- debug-frontend-browserSkill
- debug-root-causeSkill
- defend-llm-prompt-injectionSkill
- deliver-webhooksSkill
- dependency-upgradeSkill
- deploy-releaseSkill
- design-api-paginationSkill
- design-authorization-modelSkill
- design-backup-dr-recoverySkill
- design-event-sourcing-cqrsSkill
- design-multi-tenancySkill
- design-protobuf-grpc-serviceSkill
- design-relational-schemaSkill
- design-search-index-infraSkill
- design-state-machineSkill
- design-token-systemSkill
- diff-table-paritySkill
- distributed-locks-leasesSkill
- dockerfile-optimizeSkill
- encrypt-sensitive-dataSkill
- error-messageSkill
- The first 60 shown.
The file
Files
When to Use
ใช้เมื่อมี อาการ perf ที่วัดเป็นตัวเลขได้ อย่างน้อยหนึ่งอย่าง:
- endpoint/job ช้า (latency สูง, p95/p99 พุ่ง, timeout)
- memory/CPU พุ่งหรือ OOM, GC ถี่
- DB query ช้า, connection pool หมด
- bundle/build/startup ใหญ่หรือนาน
อย่าใช้ skill นี้ถ้ายังไม่มีตัวเลขยืนยันว่าช้า — ไปวัดให้ได้ baseline ก่อน มิฉะนั้นคือ premature optimization. ถ้าโจทย์คือ "correctness bug" ไม่ใช่ "speed/resource" → ใช้ skill อื่น.
กฎเหล็ก: measure ก่อน optimize เสมอ. ห้าม optimize จากการเดา.
Steps
- กำหนด target ที่วัดได้ก่อนเริ่ม. เขียนเป็นตัวเลข เช่น "p95 ของ
GET /orders< 200ms" หรือ "RSS < 512MB ที่ 1k req/s". ระบุ workload/dataset ที่จะใช้ reproduce (input size, concurrency, env). ถ้าไม่มี repro ที่เสถียร ให้สร้างก่อน (script/benchmark/load test) — เพราะตัวเลขที่ noisy เชื่อไม่ได้. - วัด baseline แล้วหา hotspot จริงด้วย profiler — ไม่ใช่อ่านโค้ดแล้วเดา. เลือกเครื่องมือตาม layer:
- CPU/wall time (app): sampling profiler ของภาษานั้น (เช่น
py-spy/cProfile,--prof+flamegraph /clinic flame(Node),pprof(Go), async-profiler (JVM),perf+ flamegraph). อ่าน flame graph หา frame ที่กว้างสุด (กิน wall/CPU มากสุด). - DB:
EXPLAIN ANALYZEบน query ที่ต้องสงสัย ดู rows, Seq Scan, nested loop, actual time. เปิด slow query log /pg_stat_statementsหา query ที่กินเวลารวมมากสุด. - N+1: ดู query log/APM count — ถ้าจำนวน query โตตาม N ของผลลัพธ์ = N+1.
- Memory: heap snapshot / heap profiler (
take_heapsnapshot,memory_profiler,pprof -alloc_space, Gopprof heap) เทียบ 2 snapshot หา object ที่โตเรื่อยๆ (leak) หรือ allocation hotspot. - Async/blocking IO: หา blocking call ใน hot path (sync IO ใน event loop, lock contention, sequential awaits ที่ควร parallel).
- Frontend/bundle: bundle analyzer หา module ใหญ่; Lighthouse/perf trace หา long task, layout thrash.
- CPU/wall time (app): sampling profiler ของภาษานั้น (เช่น
- จัดอันดับ candidate ตาม impact, แก้ทีละจุดบนสุด. เรียงตาม "% ของเวลา/หน่วยทรัพยากรที่จุดนั้นกิน" จาก profiler. แก้จุดที่กิน 60% ก่อนจุดที่กิน 2% เสมอ. แก้ทีละ change เพื่อ attribute การปรับปรุงได้ชัด — อย่าแก้ 5 อย่างพร้อมกันแล้วไม่รู้อันไหนช่วย.
- เลือก fix ตาม root cause (จากแพงไปถูกในแง่ effort/maintainability):
- N+1 query → batch (
IN (...)/WHERE id = ANY),JOIN, eager-load (include/preload/dataloader). ลด round-trip ไม่ใช่แค่ทำ query เร็วขึ้น. - Algorithmic → O(n²)→O(n) ด้วย hash map/set แทน nested loop; O(n)→O(log n)/O(1) ด้วย index/sorted structure. นี่ให้ผลโตตาม N — มักคุ้มสุด.
- Missing DB index → เพิ่ม index ให้ตรง predicate/sort/join (เช็คด้วย
EXPLAINว่ามันถูกใช้จริงหลังเพิ่ม). ระวัง write overhead. - Allocation/GC → ลด allocation ใน hot loop (reuse buffer, ตัด intermediate copy/
map().filter().map()chain บน array ใหญ่, streaming แทน load-all-in-memory). - Blocking/serial IO → parallelize (
Promise.all/goroutine/async gather) งานที่ independent; ย้าย blocking call ออกจาก hot path/event loop. - Repeated expensive compute → cache/memoize (กำหนด invalidation ชัด), หรือ precompute.
- Over-fetching → select เฉพาะ column ที่ใช้, paginate, lazy-load, defer.
- N+1 query → batch (
- วัดหลังแก้ด้วย repro/profiler เดิม แล้วรายงาน before/after เป็นตัวเลข. เช่น
p95 820ms → 140ms (-83%),queries/req 312 → 3,RSS 1.2GB → 380MB. ถ้าตัวเลขไม่ดีขึ้นจริง → revert การแก้นั้น (มันไม่ใช่ hotspot จริง) แล้วกลับไป step 3. - รัน regression test/lint ให้เขียว. confirm ว่าไม่ได้แลก correctness เพื่อ speed. ถ้าไม่มี test ครอบ behavior ที่เพิ่งแก้ → เขียนเพิ่มก่อน merge.
Common Errors / Gotchas
- เดา hotspot จากการอ่านโค้ด. จุดที่ "ดูช้า" มักไม่ใช่จุดที่กินเวลาจริง. ต้องมี profiler/EXPLAIN ยืนยัน — ทุกครั้ง.
- วัดใน dev/debug build หรือ dataset เล็ก. debug mode, source map, dataset 10 แถวให้ profile คนละเรื่องกับ prod. วัดบน build + data size ใกล้ prod.
- Cold start / JIT / cache warm-up บิดเบือนเลข. ทิ้ง run แรกๆ (warmup), วัดหลายรอบเอา median/p95 ไม่ใช่ค่าครั้งเดียวที่ noisy.
EXPLAIN(planner estimate) ≠EXPLAIN ANALYZE(actual). ดู actual time + actual rows; estimate โกหกได้ถ้า stats เก่า (ANALYZEtable ก่อน).- แก้แล้ว query เร็วแต่ throughput แย่ลง — เพิ่ม index ทำ read เร็วแต่ write ช้า/ใหญ่ขึ้น. ดู trade-off ทั้งระบบ ไม่ใช่แค่ตัวเลขเดียว.
- Cache ที่ไม่มี invalidation = correctness bug รอเวลา. มี cache ต้องตอบได้ว่า invalidate เมื่อไหร่.
- Micro-optimize จุดที่กิน 1%. เปลี่ยน
forเป็นwhile, ตัด+ทีละนิด ในจุดที่ไม่ใช่ hotspot = เสียเวลา + โค้ดอ่านยากขึ้น ไม่ได้อะไร. - แลก correctness เพื่อ speed — ลด assertion, ข้าม validation, อ่าน stale data โดยไม่ตั้งใจ. ห้ามเด็ดขาด: เร็วแต่ผิด = พัง.
- N+1 ที่ซ่อนอยู่หลัง ORM lazy-load/serializer. มองไม่เห็นในโค้ดตรงๆ — ต้องดู query log จริง.
Verify
ถือว่าสำเร็จเมื่อครบทุกข้อ:
- มี before/after เป็นตัวเลข จาก repro/profiler เดิม และผ่าน target ที่ตั้งไว้ใน step 1
- การปรับปรุงมาจาก hotspot จริงที่ profiler ชี้ (อธิบายได้ว่าทำไมมันช่วย ไม่ใช่ "ลองแล้วเร็วขึ้น")
- regression test + lint เขียว — correctness ไม่ถูกแลก
- ไม่มี trade-off ที่ซ่อน (write/memory/maintainability แย่ลงโดยไม่ได้ตั้งใจ) หรือถ้ามีก็ระบุชัดและยอมรับได้
- วัดบน build/dataset ใกล้ prod ไม่ใช่ dev/toy data
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

