| name | performance-profiler |
| description | Application performance profiling: identify CPU hotspots, memory leaks, slow queries, N+1 problems — Node.js, Python, and database performance analysis |
Performance Profiler Skill
When to activate
- Application is slow and you don't know why
- CPU usage is unexpectedly high under load
- Memory usage grows over time (potential leak)
- Database queries are taking too long
- A specific endpoint or function is slow under profiling
- Preparing for a load test and need a performance baseline
When NOT to use
- Network latency from third-party APIs — instrument at the boundary, then the problem is upstream
- Infrastructure sizing — that's capacity planning, not profiling
- Frontend performance — use browser DevTools Lighthouse, not backend profiling
Instructions
Node.js profiling
Profile a Node.js application for performance bottlenecks.
Symptom: [high CPU / high memory / slow response times / event loop lag]
Environment: [Node version, Express/Fastify/NestJS/other]
Deployment: [single process / cluster / container]
Load profile: [concurrent users, requests/second]
Step 1 — Identify the bottleneck type:
CPU-bound (high CPU, slow responses):
node --prof app.js # Run with V8 profiler
node --prof-process isolate-*.log # Process the profile
Look for: functions consuming >5% of CPU
Event loop lag (slow intermittently, not under CPU):
Use: clinic.js or autocannon
npx clinic doctor -- node app.js
npx autocannon -c 100 -d 30 http://localhost:3000/api/endpoint
Look for: blocking synchronous operations in async context
Memory leak (RSS grows over time, never drops):
node --expose-gc app.js # Enable manual GC
Take heap snapshots at intervals:
const v8 = require('v8')
v8.writeHeapSnapshot() # Call via endpoint
Load in Chrome DevTools → Memory → compare snapshots
Look for: retained objects that shouldn't be retained
Async bottleneck (slow I/O):
Use: async_hooks to trace context propagation
Or: OpenTelemetry auto-instrumentation (traces each await)
Step 2 — Fix by category:
- Synchronous CPU work in hot path → Worker threads or off-load to queue
- N+1 database queries → batch with DataLoader or join
- Unbounded caches → LRU cache with max size
- Large JSON serialisation → use fast-json-stringify
- Missing indexes → check query plan (EXPLAIN ANALYZE)
Produce: top 3 bottlenecks found + specific fix for each.