Profile Rust code using samply to identify CPU bottlenecks. Use when performance is slow, before optimizing, or when the user asks to profile.
Profile Rust binaries to find CPU bottlenecks and allocation pressure using samply, then use OS-level memory evidence when RSS or fragmentation is the symptom.
# 1. Ensure profiling profile exists in Cargo.toml (see reference.md)
# 2. Build with debug symbols
cargo build --profile profiling
# 3. Profile (opens Firefox Profiler UI)
samply record ./target/profiling/<binary> [args...]
# 4. Or save for CLI analysis
samply record --save-only -o profile.json ./target/profiling/<binary>
python3 ~/.agents/skills/rust-profiling/scripts/analyze_profile.py profile.json
| File | Purpose |
|------|---------|
| reference.md | Cargo.toml setup, samply options, troubleshooting |
| examples.md | Common profiling scenarios and analysis patterns |
| optimization.md | Post-profiling fixes: source patterns, release-profile tuning, PGO, BOLT, what doesn't work |
| scripts/analyze_profile.py | CLI tool to analyze saved profile.json files |
| Pattern | Meaning | Action |
|---------|---------|--------|
| High self-time | Function itself is slow | Direct optimization target |
| High total-time | Called often or slow callees | Check call frequency |
| malloc/alloc in hot path | Allocation overhead | Preallocate, reuse, pool, or use bounded/shared buffers |
| RSS grows then plateaus while profiles show allocation churn | Possible allocator fragmentation, not necessarily a leak | Compare allocators, then reduce high-rate small allocations |
| pthread_mutex/parking_lot | Lock contention | Reduce lock scope or use lock-free |
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer