Notre avis
Profile le CPU et la mémoire de code Go avec pprof pour identifier les goulots d'étranglement de performance.
Points forts
- Analyse détaillée des hotspots CPU et des allocations mémoire
- Génération de rapports tabulaires avec observations exploitables
- Suggestions d'optimisation spécifiques avec références aux fonctions
Limites
- Nécessite que le code soit exécutable avec des benchmarks (go test -bench=.)
- Ne fonctionne que pour le langage Go
- Les profils sont générés sur un benchmark, pas sur une exécution réelle
Lors de l'investigation de surconsommation CPU ou mémoire dans une application Go.
Pour du profilage en production ou pour des langages autres que Go.
Analyse de sécurité
SûrThe skill uses standard Go tooling for profiling, with no destructive or exfiltrating behaviors. Package path is user-provided but confined to Go test contexts. No network calls or disablement of safety features.
Aucun point d'attention détecté
Exemples
/profile cpu ./internal/index//profile memory ./.../profile all .name: profile description: Run CPU and memory profiling with pprof to identify performance hotspots. Use when investigating high resource usage. disable-model-invocation: true argument-hint: "cpu|memory|all package-path"
CPU and Memory Profiling
Profile Go code to identify CPU hotspots and memory allocators using pprof.
Usage
/profile cpu ./internal/index/- CPU profiling on index package/profile memory ./internal/repo/- Memory profiling on repo package/profile all ./...- Both CPU and memory on all packages
Steps
-
Parse arguments
- First argument: Profile type (
cpu,memory, orall) - Second argument: Package path (defaults to
./...)
- First argument: Profile type (
-
Create profile output directory
mkdir -p .profiles -
Run profiling benchmarks
For CPU profiling:
go test -cpuprofile=.profiles/cpu.prof -bench=. $PACKAGE 2>&1For memory profiling:
go test -memprofile=.profiles/mem.prof -bench=. $PACKAGE 2>&1 -
Analyze CPU profile
go tool pprof -top -cum .profiles/cpu.prof 2>&1 | head -30Identify:
- Top 10 CPU consumers by cumulative time
- Functions with high self time (computation hotspots)
- Unexpected entries (potential optimization targets)
-
Analyze memory profile
go tool pprof -top -alloc_space .profiles/mem.prof 2>&1 | head -30Identify:
- Top allocators by total bytes
- Functions with high allocation counts
- Potential sources of GC pressure
-
Generate flamegraph data (if requested)
go tool pprof -raw .profiles/cpu.prof > .profiles/cpu.raw -
Report findings
Structure the report as:
CPU Hotspots
| Function | Self% | Cum% | Observation | |----------|-------|------|-------------|
Memory Allocators
| Function | Bytes | Allocs | Observation | |----------|-------|--------|-------------|
Optimization Suggestions
- List specific, actionable recommendations
- Reference line numbers where applicable
- Note any patterns (e.g., repeated allocations in loops)
Interpreting Results
CPU Profile Indicators
- High self%: Direct computation hotspot
- High cum% but low self%: Calls expensive functions
- runtime.*: GC or scheduler overhead
Memory Profile Indicators
- High alloc_space: Total memory pressure
- High alloc_objects: GC pressure from many small allocations
- Repeated patterns: Loop allocations, string concatenation
Common Hotspots in Veloria
Watch for issues in:
(*Index).Search- Regex compilation, line reading(*Repository).Load- Index file mapping(*IndexedExtension).Update- Hot-swap operations- HTTP handlers - JSON marshaling, response writing
Cleanup
Profile files are stored in .profiles/. Add to .gitignore if not already present.
Expert Next.js App Router
Developpement
Un skill qui transforme Claude en expert Next.js App Router.
Générateur de README
Developpement
Crée des README.md professionnels et complets pour vos projets.
Rédacteur de Documentation API
Developpement
Génère de la documentation API complète au format OpenAPI/Swagger.