Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

investigating-performance

БесплатноБез исполняемых скриптовНе проверен

Use when something is too slow, uses too much memory or CPU, degrades under load, or times out — and before making any change intended to speed something up…

osmonteroот osmontero★ 18 звёзд на GitHub

Об этом скилле

Investigating Performance

Overview

Performance work fails in a specific way: the engineer reads the code, forms an intuition about what must be slow, optimizes that, and ships a change that measurably does nothing. The bottleneck is somewhere else, because the bottleneck is almost always somewhere else.

Core principle: Measure, localize, change one thing, measure again. Intuition selects what to measure; it never selects what to fix.

Companion skills: systematic-debugging — same discipline applied to wrongness rather than slowness. Both refuse to act before the cause is located.

The Iron Law

NO OPTIMIZATION WITHOUT A MEASUREMENT THAT NAMES THE BOTTLENECK

You must be able to say "X accounts for N% of the time" before you change X. Not "X looks expensive." Not "X is O(n²)." A measurement, with a number.

No exceptions:

  • Not for "this is obviously the slow part" — obvious is what makes it worth measuring
  • Not for "the fix is cheap anyway" — a cheap fix to a non-bottleneck is pure risk with zero payoff
  • Not for changes you would make on style grounds regardless. Make them; just don't call it performance work

The corollary: a change without an after-measurement is not an optimization, it is a guess that shipped.

Step 0: Define the Target

"Slow" is not a bug report. Write down all four before touching anything:

Example
Metric End-to-end latency of POST /documents
Statistic p99, not mean — means hide the problem users complain about
Load 200 concurrent clients, production-shaped data volume
Target Under 300ms, from 2.1s today

Without a target you cannot tell when you are done, and performance work has no natural stopping point. Without a statistic you will optimize the average and never touch the tail that generated the complaint.

Step 1: Reproduce It

You need a harness that produces the slow behavior on demand, repeatably.

  • Real data shape. A thousand dev rows will not reproduce a missing index; ten million will.
  • Warm up first, then measure. JIT compilation, connection pools, and page cache all make the first run a different program.
  • Repeat and take the distribution. A single timing is noise. Report min/p50/p99, not one number.
  • Pin the environment. Same machine, same build flags, no other load. Especially: measure a production build — a dev-mode framework build can be 10× slower and is not the thing you are shipping.

If you cannot reproduce it locally, measure in the environment where it happens. Production profiling at low sample rates is safe and is better than a faithful reproduction you do not have.

Step 2: Characterize Before Profiling

Two minutes here saves an hour of profiling the wrong dimension.

Observation What it implicates
Slow on the first call, fast after Cold cache, lazy init, connection setup, JIT
Slow always, uniformly An algorithm or a per-call fixed cost
Fast at low load, cliff at high load Contention, pool exhaustion, or a queue — not the code path
Time scales with input size superlinearly Complexity bug — find the nested loop before you profile
p50 fine, p99 terrible GC pauses, lock convoy, retries, a rare slow path
CPU at 100% Compute-bound → CPU profile
CPU low, latency high Waiting — I/O, network, lock, or a sleep
Memory grows and never returns Retention, not allocation rate → heap profile with two snapshots
Slow only in production Data volume, concurrency, network topology, or config

A quick sanity check: concurrency ≈ throughput × latency (Little's Law). If you serve 100 req/s at 2s each, roughly 200 requests are in flight. If the pool holds 20 connections, the pool is the bottleneck and no amount of query tuning will help.

Step 3: Profile the Right Dimension

Profile the dimension the characterization implicated. A CPU profile of an I/O-bound program shows an idle process and teaches you nothing.

Dimension When What it shows
CPU CPU pegged, compute-bound Which functions burn cycles
Allocation High GC time, memory churn Where garbage comes from
Heap (in-use) Memory grows without bound What is retained, and by whom
Block / wait Low CPU, high latency What the program waits on
Mutex / lock Degrades with concurrency Contended locks
Execution trace Latency spikes with no obvious owner GC pauses, scheduler stalls, serialization
Query plan The database is involved at all Scans, bad join order, missing indexes

Exact invocations per stack — Go, Node, Python, browser, SQL, system-level: references/profiling-tools.md.

Read the profile top-down by cumulative time, and be suspicious of flat profiles. A profile with no peak usually means the cost is spread across a call made far too many times — count the calls, don't just time t

Полный SKILL.md на GitHub

Установить investigating-performance в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

references/profiling-tools.md

FAQ

Что делает скилл investigating-performance?

Use when something is too slow, uses too much memory or CPU, degrades under load, or times out — and before making any change intended to speed something up. Triggers include "this is slow", "optimize this", "high latency", "p99", "memory leak", "it's fine locally but not in production", "the query takes forever", "reduce bundle size", and any request to make code faster.

Как установить скилл investigating-performance?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл investigating-performance запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить investigating-performance с