rust-profiling

v2026.09.24

Profile Rust code using samply and related evidence to identify CPU bottlenecks, allocation hot paths, and allocator-fragmentation symptoms. Use when performance is slow, RSS grows unexpectedly, before optimizing, or when the user asks to profile.

GitHub
安装命令
npx skhub add blacktop/rust-profiling
Markdown
SKILL.md

Rust Profiling with Samply

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.

Quick Start

# 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

FilePurpose
reference.mdCargo.toml setup, samply options, troubleshooting
examples.mdCommon profiling scenarios and analysis patterns
optimization.mdPost-profiling fixes: source patterns, release-profile tuning, PGO, BOLT, what doesn't work
scripts/analyze_profile.pyCLI tool to analyze saved profile.json files

When to Use

  • Performance is slower than expected
  • RSS or heap usage grows unexpectedly under load
  • Before optimizing (measure first!)
  • After optimization (verify improvement)
  • Investigating CPU-bound operations or allocation-heavy hot paths

When NOT to Use

  • The task is a Rust correctness bug, API design question, or refactor without a performance symptom.
  • The user already has a narrow benchmark request that does not need profiling guidance.
  • The issue is build time, binary size, or dependency hygiene rather than runtime CPU, memory, or contention.

What to Look For

PatternMeaningAction
High self-timeFunction itself is slowDirect optimization target
High total-timeCalled often or slow calleesCheck call frequency
malloc/alloc in hot pathAllocation overheadPreallocate, reuse, pool, or use bounded/shared buffers
RSS grows then plateaus while profiles show allocation churnPossible allocator fragmentation, not necessarily a leakCompare allocators, then reduce high-rate small allocations
pthread_mutex/parking_lotLock contentionReduce lock scope or use lock-free
发现
标签

此技能尚未发布标签。

版本
最新版本元数据

版本

v2026.09.24

发布时间

Sep 24, 2026

分类

未分类

许可证

未指定

源路径

ai/skills/rust-profiling

默认分支

master

最新提交

7a45f0c

Tree SHA

775c40e