agentleFS
juninmdjuninmd/skills/.agents/skills/performance-engineering/SKILL.md

performance-engineering

Skill2 starsChanged 5 days agoMITView on GitHub

Measure and reduce latency, memory, Core Web Vitals, and cloud or token spend. Use for endpoint profiling, k6 load tests, bottlenecks, N+1 queries, memory leaks, LCP/INP, autonomous metric loops, and rightsizing costs. Trigger on 'this is slow', 'load test this', 'memory keeps growing', 'improve LCP', 'the cloud bill is too high', 'cut token cost'.

10 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use clack-cli-patterns, drag-to-reorder 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.
  • openchamberSkill

    clack-cli-patterns

    Use when creating or modifying OpenChamber CLI commands, prompts, terminal output, non-TTY behavior, `--quiet`, or `--json` behavior.

    Also in 3 projects that use this

  • openchamberSkill

    drag-to-reorder

    Use when implementing or modifying OpenChamber sortable or drag-to-reorder behavior, especially `@dnd-kit`, touch/mobile interactions, variable-width items, or wrapping layouts.

    Also in 3 projects that use this

  • gabriellstSkill

    desktop-shell

    Work on the CODM desktop shell — the Tauri v2 host (packages/app/tauri), the react client-side services DI (packages/app/react/src/services — ports + platform services + Container/Token + ServicesProvider), sidecar supervision, or any OS-integration capability (folder picker, notifications, badge, secrets, autostart). Use whenever a task mentions Tauri, the desktop app, sidecars, or an OS capability the react console needs.

    Also in 3 projects that use this

  • +9 more from openchamber

The file

We split this skill into the rules it gives an agent

7 rules. 0 are common, 5 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 8 edited versions we read keep these.

  • 5

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Write the target down first: the metric, the percentile, and today's number.

    line 22
  2. Very specific:

    Write the target down before touching code: the user-visible metric, the percentile that matters (p50/p95/p99, RPS, RSS), and today's …

    line 25
  3. Distinctive:

    Add a regression guard: a CI benchmark, a budget assertion, or an alert threshold.

    line 30
  4. Distinctive:

    USE/RED depth, percentile math, and measuring before optimizing: measurement-methodology.md

    line 83
  5. Distinctive:

    Stop when the target is met, or when the next profile entry is smaller than the noise floor.

    line 96
  6. Very specific:

    When the profile points at structure — chatty I/O across a boundary, needless synchronization, a fan-out that should be one call — stop …

    line 97
  7. Distinctive:

    Test against production-sized data.

    line 101

“Common” is measured: kept by at least 6 in 10 of the 8 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Performance Engineering

Not this skill: a correctness bug that is merely slow to hit (its domain skill), or an active incident with no measurement yet (observability).

Preflight

# Baseline before any change — you cannot prove an improvement without it.
# autocannon fits an HTTP endpoint; swap for the load generator that fits the
# target (k6, wrk, a DB benchmark, a profiler) when it isn't one.
autocannon -c 50 -d 30 http://localhost:3000/endpoint | tee /tmp/before.txt
nproc && free -m && cat /sys/fs/cgroup/cpu.max 2>/dev/null   # is the box throttled?

Write the target down first: the metric, the percentile, and today's number. "Make it faster" is not a target.

Workflow

  1. Write the target down before touching code: the user-visible metric, the percentile that matters (p50/p95/p99, RPS, RSS), and today's baseline. "Make it faster" is not a target.
  2. Reproduce the slowness under a repeatable load — fixed input, cache state stated, environment recorded.
  3. Profile before hypothesizing. Pick the layer the symptom points at; guessing here is how a week disappears into the wrong subsystem.
  4. Attack the top of the profile only. One change per measurement cycle.
  5. Re-measure against the baseline under the same load. Keep the change only if the metric moves beyond run-to-run variance and correctness holds.
  6. Add a regression guard: a CI benchmark, a budget assertion, or an alert threshold.

Pick the Profiler by Symptom

Two lenses choose what to look at before any tool runs: USE — Utilization, Saturation, Errors — per resource (CPU, memory, disk, network), from Brendan Gregg's Systems Performance; and RED — Rate, Errors, Duration — per request-driven service. The table below already routes along both: rows above the fold are USE questions about a resource, rows below are RED questions about a request path.

SymptomLayerTool
CPU pegged, one endpoint slowCPUnode --cpu-prof · py-spy record -p <pid> · pprof
Memory grows and never returnsHeapnode --heapsnapshot-signal=SIGUSR2 · tracemalloc · objgraph
Latency fine alone, awful under loadConcurrencyevent-loop lag probe · pool saturation metrics
One request slow, CPU idleI/O waitdistributed trace waterfall
Slow only with real data volumeDatabaseEXPLAIN (ANALYZE, BUFFERS) · pg_stat_statements
Throughput plateaus below CPU limitSaturationconnection pool size, queue depth, thread pool
# Node: CPU profile of a running server
node --cpu-prof --cpu-prof-dir=./prof server.js
# Python: sample a live process without stopping it
py-spy record -o profile.svg --pid $(pgrep -f 'python app.py')
# Load, with a fixed shape so runs are comparable
autocannon -c 50 -d 30 -p 10 http://localhost:3000/endpoint

The N+1 Signature

One query in the log, then N nearly identical ones with a different id. It never shows up locally because N is 3 with seed data and 4,000 in production. Count queries per request in a test and assert the count — that assertion catches the regression a latency benchmark misses, in CI, before it ever reaches a profiler.

Connection Pool Exhaustion

SymptomLikely causeFix
Latency climbs under load; app CPU and DB CPU both idlepool smaller than concurrent demand; requests queue for a connectionraise the pool to match concurrency, or shed load; watch queue-wait time, not just DB-side metrics
Intermittent "timeout acquiring connection from pool"leaked connections — a missing close/release on an error pathaudit for checkout without a finally/using/context-manager release; alert on pool checkouts that never return
Fine alone, collapses when replicas scale outshared DB max_connections hit across all replicas combinedsize each replica's pool against the DB ceiling divided by replica count, or front the DB with a pooler (PgBouncer)
p99 fine, throughput plateaus below CPU/DB capacitythe pool itself is the saturation resource, not the codethis is a USE-method saturation finding — resize the pool before profiling application code further

A pool is a bounded resource like a CPU core; it saturates the same way, and the fix is sizing or shedding, never a code-level micro-optimization.

Noise Floor

A result inside run-to-run variance is not a result. Averages hide exactly the tail a user feels: a service reporting p50 = 50ms and p99 = 4s has a "great" mean while one request in a hundred waits 80x longer — percentiles, not the mean, are what an SLO should be built on (Kleppmann, Designing Data-Intensive Applications, ch. 1).

GuardWhy
Discard the first runsJIT warmup, cold caches, lazy imports
Report median and p95/p99A better median with a worse tail is a worse system
Repeat the baseline, not just the fixMachine drift is indistinguishable from your change
Watch CPU quota and thermalsA throttled container fakes a regression perfectly
Sample in independent processesIn-process iterations autocorrelate through JIT, GC, and thermal state; a significance test over them assumes independence it does not have
Decide with a test, not an eyeballMann-Whitney U over 7+ samples per side, and an effect larger than max(noise band, 2 x stdev) — at n=7 only differences around 1 sigma are detectable

Reference Routing

  • Practical performance cases: real-world-cases.md
  • Profiling by layer (Node, Python, browser, SQL): profiling-playbook.md
  • Caching, batching, and load-test design: optimization-patterns.md
  • USE/RED depth, percentile math, and measuring before optimizing: measurement-methodology.md

See Reference Map for specialized references and sub-domain guides.

Stop

  • There is no profile. Stop guessing — intuition about hot paths is wrong often enough to be worthless.
  • The delta sits inside run-to-run variance. That is not a result; keep measuring or revert.
  • The profile points at structure, not code. Stop tuning and route it to software-architecture.

Rules

  • Hand off production alerting to observability, frontend tuning to frontend-engineering, and backend bottlenecks to backend-systems.
  • No optimization without a profile. The bottleneck is measured, never guessed — intuition about hot paths is wrong often enough to be worthless. Knuth's "premature optimization is the root of all evil" (Structured Programming with go to Statements, 1974) is an argument for measuring before tuning, not for skipping tuning; it names the unmeasured 97% as the trap, not the measured 3% as the excuse.
  • Rightsizing is a tradeoff, not a one-way lever: over-provisioning is a silent, recurring cost; under-provisioning is a latency risk that pages someone. State which one is being traded before resizing anything — see cost-engineering.
  • Stop when the target is met, or when the next profile entry is smaller than the noise floor.
  • When the profile points at structure — chatty I/O across a boundary, needless synchronization, a fan-out that should be one call — stop tuning and delegate to software-architecture.
  • Caching is the wrong fix for avoidable work: a cache over an N+1 still fires on every miss and now serves stale rows. Fix the access pattern first, then delegate cache design to backend-systems.
  • Reject micro-optimizations that complicate code without moving the user-visible metric.
  • Load tests never run against production without explicit approval.
  • Test against production-sized data. A bottleneck that only appears at scale is invisible locally, and that is exactly the one that pages you.
  • Browser latency, bundle size, and Core Web Vitals belong to web-performance; spend to cost-engineering; a crash or wrong answer to observability.
  • Turning a proven target into an unattended keep-or-revert loop is metric-loop; gating a branch on the benchmark delta is test-engineering.

Checklist

  • Metric, percentile, target, load, and environment recorded before the first change.
  • A profile — not a hypothesis — chose what to fix.
  • One change per measurement cycle; baseline re-measured alongside it.
  • Improvement exceeds run-to-run variance, with tails reported, not just the median.
  • Correctness unchanged and a regression guard is in place.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.