TOKREPO · Arsenal IA
Nouveau · cette semaine

Pack Profilage et Optimisation de Performance

Dix outils pour l'ingénieur face à un endpoint lent, une UI saccadée ou une requête de 8 secondes. Baseline d'abord, puis flamegraph, puis correction d'un hot path, puis tests de régression — avec des agents IA qui lisent les profils au lieu de deviner.

10 ressources

What's in this pack

This is the rig for the engineer who just got pinged: "the /search endpoint is taking 8 seconds, can you look?" — or "the dashboard freezes for 2 seconds when I open it." Ten picks, each with a clear role in a five-step loop: baseline → profile → diagnose → fix → regression-test.

Every tool here is open-source or has a free tier that covers the loop. No "contact sales," no SaaS-only telemetry. The AI agents (Performance Profiler, GraphQL Performance Optimizer, Postgres MCP Pro) read the actual profile output — they don't pattern-match on your code and hallucinate "add an index here."

Install in this order

  1. Claude Code Agent: Performance Profiler — the orchestrator. Install first because it's the agent you'll point at flamegraphs and traces. It knows the difference between a CPU profile, an off-CPU profile, and a wall-clock profile, and won't suggest "add caching" when the bottleneck is GC pauses.
  2. Lighthouse — frontend baseline. Run lighthouse https://your.url --output html before touching anything. Save the report. Every later change gets a re-run for diff. This is your frontend before-picture.
  3. Size Limit — JS bundle perf budget. Wire it into CI on day one. Once you set size-limit: [{ path: 'dist/*.js', limit: '200 KB' }], every PR that bloats the bundle gets blocked before merge. Cheapest performance win in the stack.
  4. FlameGraph — Brendan Gregg's perl/SVG flamegraph generator. The actual file format the rest of the ecosystem speaks. Install once, every other profiler in this pack can pipe into it: perf script | stackcollapse-perf.pl | flamegraph.pl > out.svg.
  5. async-profiler — low-overhead JVM sampling profiler. For Java/Kotlin/Scala services. ~1% overhead in production, emits collapsed-stack format that pipes straight into FlameGraph. Captures CPU, allocation, lock contention, and wall-clock in one tool.
  6. BCC (BPF Compiler Collection) — eBPF tracing for Linux. Reach for this when the bottleneck is below your runtime — syscalls, disk I/O, network, page faults. biolatency, tcpretrans, funccount are the three commands you'll use first.
  7. Grafana Pyroscope — continuous profiling backend. Once you've fixed one slow endpoint, install Pyroscope so the next regression shows up as a flamegraph diff in a dashboard, not a Slack message at 11pm. Pairs with FlameGraph format natively.
  8. Postgres MCP Pro — index tuning + safe SQL MCP. For "the query is slow" — point this MCP at your Postgres, ask the agent to explain a query plan, and it returns a real EXPLAIN ANALYZE plus index suggestions the agent itself validated by running EXPLAIN again. Not a hallucination.
  9. Claude Code Agent: GraphQL Performance Optimizer — for the N+1 query problem that every GraphQL gateway eventually hits. Reads your resolvers, finds the unbatched DB calls, suggests DataLoader patterns specific to your schema.
  10. k6 — JavaScript-scripted load testing. The regression net. After every fix, run the same k6 script against staging and compare p50/p95/p99. If you can't reproduce the slowdown with a k6 script, you can't prove the fix.

How they fit together

┌─ BASELINE ─────────────────────────┐
│ Lighthouse (frontend)              │
│ k6 (backend p50/p95/p99)           │
│ Size Limit (bundle budget in CI)   │
└─────────────┬──────────────────────┘
              │ "it's slow — but where?"
              ▼
┌─ PROFILE ──────────────────────────┐
│ async-profiler (JVM)               │
│ BCC / eBPF (syscalls, I/O)         │
│ Pyroscope (continuous, in prod)    │
│ → all emit FlameGraph format       │
└─────────────┬──────────────────────┘
              │ flamegraph.svg
              ▼
┌─ DIAGNOSE (agent reads profile) ───┐
│ Performance Profiler agent         │
│ Postgres MCP Pro (query plans)     │
│ GraphQL Performance Optimizer      │
└─────────────┬──────────────────────┘
              │ "hot path is X, fix is Y"
              ▼
        FIX ONE HOT PATH
              │
              ▼
┌─ REGRESSION TEST ──────────────────┐
│ k6 (rerun same script, diff p95)   │
│ Lighthouse (rerun, diff scores)    │
│ Pyroscope (flamegraph diff)        │
└────────────────────────────────────┘

The loop is non-negotiable. Skipping baseline means you can't prove the fix. Skipping the flamegraph means you're guessing — and the LLM is guessing harder. Skipping regression means the next deploy un-fixes it silently.

Tradeoffs you'll hit

  • Pyroscope vs ad-hoc async-profiler runs — Pyroscope is continuous (always-on, low overhead, costs storage). async-profiler is on-demand (run it for 60 seconds when you suspect something, zero idle cost). Start with async-profiler; install Pyroscope only after you've fixed two regressions and want the third to be obvious from a dashboard.
  • BCC vs perf — BCC is higher-level and writes scripts in Python (readable). perf is the kernel's own profiler, lower level, slightly more universal. BCC is the friendlier on-ramp; reach for raw perf when you need a specific event source BCC doesn't expose.
  • Lighthouse local vs LH-CI — local Lighthouse is one-shot. Lighthouse-CI runs it on every PR and stores the trend. If you're past the first fix, install LH-CI; otherwise local is fine.
  • Size Limit vs Bundlephobia/Webpack Bundle Analyzer — Size Limit blocks CI on regression (proactive). Analyzers just show you the bundle (reactive). Both are useful; Size Limit is the one that prevents the next 50 KB of accidental bloat.
  • k6 vs Artillery vs Locust — k6 wins on script ergonomics (real JavaScript, not YAML), built-in p95/p99 reporting, and Grafana integration. Pick Artillery if your team is YAML-first; pick Locust if your team is Python-first.

Common pitfalls

  • Profiling in dev, fixing for prod — your laptop's CPU is faster, the dataset is smaller, and the JVM is in interpreter mode. Always profile in an environment that mirrors prod load. Pyroscope-in-prod beats async-profiler-on-laptop every time.
  • Reading a flamegraph as a call tree — flamegraphs are sampled stacks. Width = CPU time, not call count. A wide block doesn't mean "called a lot," it means "spent a lot of CPU there."
  • Asking an LLM to optimize without showing it the profile — every "optimize this code" prompt without the actual measurement returns generic advice ("add memoization," "use a Set"). Show the agent the flamegraph or the EXPLAIN ANALYZE. That's why the Performance Profiler agent and Postgres MCP Pro exist.
  • Fixing the cold path — 80% of "optimizations" target code that runs 0.1% of the time. Always confirm the function you're rewriting is actually in the top 5 of the flamegraph.
  • No regression test after the fix — if you can't replay the slow path with a k6 script (or a SQL repro), you'll re-introduce the regression on the next refactor and not notice for two weeks.
INSTALLER · UNE COMMANDE
$ tokrepo install pack/performance-profiling-optimization
passez-la à votre agent — ou collez-la dans votre terminal
Ce qu'il contient

10 ressources prêtes à installer

Skill#01
Claude Code Agent: Performance Profiler

Performance analysis and optimization specialist. Use PROACTIVELY for performance bottlenecks, memory leaks, load testing, optimization strategies, and system performance...

by TokRepo精选·24 views
$ tokrepo install claude-code-agent-performance-profiler-233a6cf7
Skill#02
Lighthouse — Automated Web Performance Auditing by Google

An open-source tool by Google that audits web pages for performance, accessibility, SEO, and best practices, available in Chrome DevTools, as a CLI, and as a Node module.

by Script Depot·180 views
$ tokrepo install lighthouse-automated-web-performance-auditing-google-ac7ff133
Skill#03
Size Limit — Performance Budget Tool for JavaScript Apps

Size Limit calculates the real cost of running your JavaScript in a browser and throws an error if it exceeds the limit. It measures download time and parse/execution cost rather than raw bytes, integrating with CI to catch performance regressions in pull requests.

by AI Open Source·10 views
$ tokrepo install size-limit-performance-budget-tool-javascript-apps-6a3e54ed
Skill#04
FlameGraph — Stack Trace Visualization for Performance Analysis

Generate interactive SVG flame graphs from profiling data to pinpoint CPU, memory, and off-CPU bottlenecks across any language or OS.

by Script Depot·46 views
$ tokrepo install flamegraph-stack-trace-visualization-performance-analysis-343f06dc
Skill#05
async-profiler — Low-Overhead Sampling Profiler for Java

A low-overhead sampling profiler for JVM applications that captures CPU, allocation, and lock profiles without safepoint bias using perf_events and AsyncGetCallTrace.

by Script Depot·47 views
$ tokrepo install async-profiler-low-overhead-sampling-profiler-java-a0541a53
Skill#06
BCC — eBPF Tracing and Performance Analysis Tools for Linux

A toolkit for creating efficient kernel tracing and manipulation programs using eBPF. BCC includes over 100 ready-to-use tools for performance analysis, networking, and security observability on Linux systems.

by Script Depot·109 views
$ tokrepo install bcc-ebpf-tracing-performance-analysis-tools-linux-5abb7410
Skill#07
Grafana Pyroscope — Continuous Profiling Backend

Open-source continuous profiling backend from Grafana Labs that ingests pprof and eBPF profiles, supports label-based queries, and links traces to flamegraphs.

by Grafana Labs·130 views
$ tokrepo install grafana-pyroscope-continuous-profiling-backend-138e4edf
MCP#08
Postgres MCP Pro — Index Tuning + Safe SQL Tools

Postgres MCP Pro is an MCP server for PostgreSQL that runs safe SQL, explains plans, and recommends indexes so agents can tune databases faster.

by MCP Hub·69 views
$ tokrepo install postgres-mcp-pro-index-tuning-safe-sql-tools
Skill#09
Claude Code Agent: Graphql Performance Optimizer

GraphQL performance analysis and optimization specialist. Use PROACTIVELY for query performance issues, N+1 problems, caching strategies, and production GraphQL API...

by TokRepo精选·22 views
$ tokrepo install claude-code-agent-graphql-performance-optimizer-7b4df0b3
Skill#10
k6 — Modern Load Testing Tool Using Go and JavaScript

k6 is a modern load testing tool built by Grafana Labs. Write test scripts in JavaScript, run them in a high-performance Go runtime. Developer-centric with CLI-first workflow, CI/CD integration, and Grafana Cloud for result analysis.

by Script Depot·182 views
$ tokrepo install k6-modern-load-testing-tool-using-go-javascript-4240522f
Questions fréquentes

Questions fréquentes

I have one slow endpoint right now. Which tool do I start with?

Run k6 against it first to get a number ("p95 is 8.2s"). Then capture a flamegraph with async-profiler (JVM) or BCC (anything Linux) for 60 seconds while k6 is hammering it. Hand the flamegraph and the slow query (from your DB logs) to the Performance Profiler agent or Postgres MCP Pro. That's the entire first-fix loop — about 45 minutes if your infra is reachable.

Do I actually need both async-profiler AND Pyroscope?

For the first fix, no. async-profiler alone is enough for an on-demand capture, and the FlameGraph tools render the output. Install Pyroscope when you start fixing the second regression and realize you don't want to SSH-in-and-attach every time. Continuous profiling pays off after the third incident.

Why a GraphQL-specific optimizer agent and not just the general Performance Profiler?

GraphQL's N+1 problem is a structural anti-pattern that's hard to see in a flamegraph — the slow part is many fast queries, each individually invisible. The GraphQL Performance Optimizer agent reads your resolver code and looks for unbatched DB access patterns directly, suggesting DataLoader fixes scoped to your schema shape. The general profiler will show you "DB call wide," but not "this resolver fans out 200 calls per request."

Can I run BCC on macOS?

No. BCC is eBPF-based and Linux-kernel-only. On macOS, use Instruments (built into Xcode) for native code and async-profiler for JVM. The pack assumes a Linux production target — most servers are Linux even when your laptop isn't.

How big a Size Limit budget should I set on day one?

Measure your current bundle size, round up by 10%, set that as the limit, and ship it. The goal is to block future bloat, not to start with a heroic diet. Once CI is green and your team is used to seeing Size Limit comments on PRs, ratchet the limit down 5% every month. Most teams find 30-40% of their bundle is dead weight within a quarter.

PLUS DANS L'ARSENAL

12 packs · 80+ ressources sélectionnées

Découvrez tous les packs curatés sur la page d'accueil

Retour à tous les packs