rust-profiling

Profile Rust code using samply to identify CPU bottlenecks. Use when performance is slow, before optimizing, or when the user asks to profile.

14 stars

Best use case

rust-profiling is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Profile Rust code using samply to identify CPU bottlenecks. Use when performance is slow, before optimizing, or when the user asks to profile.

Teams using rust-profiling should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/rust-profiling/SKILL.md --create-dirs "https://raw.githubusercontent.com/blacktop/dotfiles/main/ai/skills/rust-profiling/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/rust-profiling/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How rust-profiling Compares

Feature / Agentrust-profilingStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Profile Rust code using samply to identify CPU bottlenecks. Use when performance is slow, before optimizing, or when the user asks to profile.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Rust Profiling with Samply

Profile Rust binaries to find CPU bottlenecks using [samply](https://github.com/mstange/samply).

## Quick Start

```bash
# 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
```

## Skill Files

| 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 |

## When to Use

- Performance is slower than expected
- Before optimizing (measure first!)
- After optimization (verify improvement)
- Investigating CPU-bound operations

## What to Look For

| 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 | Pool, arena, or stack allocate |
| `pthread_mutex`/`parking_lot` | Lock contention | Reduce lock scope or use lock-free |

Related Skills

We are still matching the closest adjacent skills for this page. In the meantime, continue through the full directory.