agentleFS
camilooscargbaptistacamilooscargbaptista/cto-toolkit/performance-profiling/SKILL.md

performance-profiling

Skill9 starsChanged 8 months agoMITView on GitHub

**Performance Profiling & Optimization**: Helps diagnose and fix performance issues including memory leaks, CPU bottlenecks, slow queries, high latency, and throughput problems. Covers profiling tools, flame graphs, load testing, caching strategies, and optimization techniques for Node.js, Java, Flutter, and web applications. Use whenever the user mentions 'performance', 'slow', 'memory leak', 'OOM', 'high CPU', 'latency', 'throughput', 'flame graph', 'profiling', 'load test', 'benchmark', 'cache', 'optimization', 'p99', 'response time', 'bottleneck', 'event loop', 'garbage collection', 'heap', or says 'my app is slow', 'why is this endpoint slow', 'we're running out of memory'.

37 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use intelligent-routing, bash-linux 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.
  • SKB3002Skill

    intelligent-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 5 projects that use this

  • xenitV1Skill

    bash-linux

    Bash/Linux terminal patterns. Critical commands, piping, error handling, scripting. Use when working on macOS or Linux systems.

    Also in 7 projects that use this

  • xenitV1Skill

    red-team-tactics

    Red team tactics principles based on MITRE ATT&CK. Attack phases, detection evasion, reporting.

    Also in 7 projects that use this

  • SKB3002Skill

    nextjs-react-expert

    React and Next.js performance optimization from Vercel Engineering. Use when building React components, optimizing performance, eliminating waterfalls, reducing bundle size, reviewing code for performance issues, or implementing server/client-side optimizations.

    Also in 3 projects that use this

  • MicrosoftSkill

    app-builder

    Builds and edits a model-driven Power Apps app from a natural-language intent — tables, columns, relationships, adaptive forms with sub-grids, views, Choice-column charts, business rules, business process flows, generative page intents for overview/dashboard surfaces, and an app module + sitemap. Runs an interactive authoring flow with plan approval and can download a deployed app back into an editable spec to change it. Use when the user says "build an app for X", "create a model-driven app", "make me an app to manage Y", "add a business process flow", or "edit/add to my app". Do not use it for a generic web or React app or website, Power Pages, canvas apps, or Power Automate, or when the user rules out Power Platform, Dataverse, or model-driven apps (for example "no Power Platform"). This skill stands alone and does not require /genpage — but for a standalone generative page added to an app that already exists, use /genpage instead.

    Also in 5 projects that use this

  • +7 more from xenitV1

The file

We split this skill into the rules it gives an agent

3 rules. 0 are common, 0 are distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 21 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Start with npx clinic doctor -- node app.js for quick diagnostic.

    line 44
  2. Very specific:

    Use JFR (Java Flight Recorder) for production diagnostics.

    line 48
  3. Very specific:

    Always profile in --profile mode, not debug.

    line 56

“Common” is measured: kept by at least 6 in 10 of the 21 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 Profiling & Optimization

You are a senior performance engineer helping diagnose and fix performance issues. The golden rule: measure first, optimize second. Never optimize based on intuition — profiling data tells you where the actual bottleneck is, and it's almost never where you think.

Performance Investigation Workflow

1. DEFINE    → What metric is bad? (latency, throughput, memory, CPU)
2. MEASURE   → Establish baseline with numbers
3. PROFILE   → Find the bottleneck with tools
4. HYPOTHESIZE → Form theory about root cause
5. FIX       → Make targeted change
6. VERIFY    → Measure again, confirm improvement

Identifying the Bottleneck Type

SymptomLikely BottleneckWhere to Look
High CPU, fast responsesCPU-bound computationFlame graphs, hot functions
Low CPU, slow responsesI/O-bound (DB, network, disk)Trace spans, await times
Growing memory, eventual OOMMemory leakHeap snapshots, allocation tracking
Slow under load, fast aloneContention (locks, pool, connections)Connection pools, thread contention
Spiky latency (p99 >> p50)GC pauses or resource contentionGC logs, lock contention
Degrading over timeResource leak or unbounded growthMemory trend, connection count trend

Node.js Profiling

Start with npx clinic doctor -- node app.js for quick diagnostic. Deep dive: see references/nodejs-profiling.md for CPU profiling tools (V8 --prof, Chrome DevTools --inspect, Clinic.js), event loop monitoring with thresholds and blockers, heap snapshot workflows, common memory leak patterns, and async bottleneck detection with tracing.

Java / JVM Profiling

Use JFR (Java Flight Recorder) for production diagnostics. See references/jvm-profiling.md for thread analysis, GC logging metrics (pause time, frequency, promotion rate), heap dump analysis with Eclipse MAT, and GC algorithm selection (G1GC, ZGC, Shenandoah).

Web Frontend Performance

Target Core Web Vitals: LCP <2.5s, INP <200ms, CLS <0.1. Use Chrome DevTools Performance tab for main thread analysis and bundle analyzer for size optimization. See references/load-testing.md for metrics table, profiling workflow, and common optimizations.

Flutter Profiling

Always profile in --profile mode, not debug. Monitor UI thread <16ms/frame (60fps), raster thread <16ms, widget rebuild count, and Dart heap growth. See references/load-testing.md for key metrics and common issues (widget rebuilds, image caching, isolate usage).

Load Testing

Strategy: Baseline (10 min normal) → Stress (2x-5x) → Soak (4-8 hrs) → Spike (10x burst).

Tools: k6 (JavaScript, CI-friendly), Artillery (quick tests), Gatling (complex scenarios), Locust (distributed), wrk (throughput benchmarking).

See references/load-testing.md for tool comparison, k6 example with stages and thresholds, and strategy details.

Caching Strategy

Hierarchy: Browser → CDN → Application (Redis) → Database → Disk.

When to cache: High read/write ratio, expensive to compute, tolerance for staleness, high traffic.

Invalidation: TTL (simple), write-through (consistent), write-behind (fast), cache-aside (flexible), event-driven (on domain events).

See references/load-testing.md for cache-aside pattern code and when-to-cache decision table.

Performance Checklist

## Application
- [ ] Profiled under realistic load (not just locally)
- [ ] Flame graph analyzed for CPU bottlenecks
- [ ] No N+1 database queries
- [ ] Database queries have EXPLAIN ANALYZE reviewed
- [ ] Connection pools properly sized
- [ ] Caching in place for hot data
- [ ] Async operations where possible
- [ ] No blocking operations on main thread/event loop

## Infrastructure
- [ ] Autoscaling configured and tested
- [ ] CDN for static assets
- [ ] Compression enabled (gzip/brotli)
- [ ] Database indexes for common queries
- [ ] Read replicas for read-heavy workloads

## Monitoring
- [ ] Latency percentiles tracked (p50, p90, p99)
- [ ] Memory and CPU dashboards
- [ ] Alerts on latency degradation
- [ ] Load test results baselined

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.