huiali/rust-skills/rust-performance
Claude Code and agent skill by huiali/rust-skills
- community
Checking that the SKILL.md file is still in the repository.
Performance optimization expert covering profiling, benchmarking, memory allocation, SIMD, cache optimization, false sharing, lock contention, and NUMA-aware programming.
Install
npx vskill@latest install huiali/rust-skills/rust-performanceSKILL.md
Optimization Priority
Warning: Premature optimization is the root of all evil. Make it work first, then optimize hot paths.
Solution Patterns
Pattern 1: Pre-allocation
Pattern 2: Avoid Unnecessary Clones
Pattern 3: Batch Operations
Pattern 4: Small Object Optimization
Pattern 5: Parallel Processing
Profiling Tools
| Tool | Purpose | |
|---|---|---|
cargo bench | Criterion benchmarks | |
perf / flamegraph | CPU flame graphs | |
heaptrack | Allocation tracking | |
valgrind --tool=cachegrind | Cache analysis | |
dhat | Heap allocation profiling |
Common Optimizations
Anti-Patterns to Fix
| Anti-Pattern | Why Bad | Correct Approach | |
|---|---|---|---|
| Clone to avoid lifetimes | Performance cost | Proper ownership design | |
| Box everything | Indirection overhead | Prefer stack allocation | |
| HashMap for small data | Hash overhead too high | Vec + linear search | |
| String concatenation in loop | O(n²) | with_capacity or format! | |
| LinkedList | Cache-unfriendly | Vec or VecDeque |
Advanced: False Sharing
Symptom
- One CPU core at 90%+
- High LLC miss rate in perf
- Many atomic RMW operations
- Adding threads makes it slower
Diagnosis
Solution: Cache Line Padding
Lock Contention Optimization
Symptom
- Most time spent in mutex lock/unlock
- Performance degrades with more threads
- High system time percentage
Solution: Thread-Local Sharding
NUMA Awareness
Problem
Solution
Tools
Data Structure Selection
| Scenario | Choice | Reason | |
|---|---|---|---|
| High-concurrency writes | DashMap or sharding | Reduces lock contention | |
| Read-heavy, few writes | RwLock<HashMap> | Read locks don't block | |
| Small dataset | Vec + linear search | HashMap overhead higher | |
| Fixed keys | Enum + array | Zero hash overhead |
Read-Heavy Example
Common Performance Traps
| Trap | Symptom | Solution | |
|---|---|---|---|
| Adjacent atomic variables | False sharing | #[repr(align(64))] | |
| Global Mutex | Lock contention | Thread-local + merge | |
| Cross-NUMA allocation | Memory migration | NUMA-aware allocation | |
| Frequent small allocations | Allocator pressure | Object pooling | |
| Dynamic string keys | Extra allocations | Use integer IDs |
Review Checklist
When optimizing performance:
- [ ] Profiled to identify bottleneck
- [ ] Bottleneck confirmed with measurements
- [ ] Algorithm is optimal for use case
- [ ] Data structure appropriate
- [ ] Unnecessary allocations removed
- [ ] Parallelism exploited where beneficial
- [ ] Cache-friendly data layout
- [ ] Lock contention minimized
- [ ] Benchmarks show improvement
- [ ] Code still readable and maintainable
Verification Commands
Common Pitfalls
1. Premature Optimization
Symptom: Optimizing before profiling
Fix: Profile first, optimize hot paths only
2. Micro-optimizing Cold Paths
Symptom: Spending time on code that rarely runs
Fix: Focus on hot loops (90% of time in 10% of code)
3. Trading Readability for Minimal Gains
Symptom: Complex code for <5% improvement
Fix: Only optimize if gain is significant (>20%)
Performance Diagnostic Workflow
Related Skills
- rust-concurrency - Parallel processing patterns
- rust-async - Async performance optimization
- rust-unsafe - Zero-cost abstractions with unsafe
- rust-coding - Writing performant idiomatic code
- rust-anti-pattern - Performance anti-patterns to avoid
Localized Reference
- Chinese version: SKILL_ZH.md - 完整中文版本,包含所有内容
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/rust-performance/SKILL.md
Popularity
- Repository stars
- 20
- Repository forks
- 4
- 7-day trend score
- 15
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 19 Mar 2026, 7 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/huiali/rust-skills/rust-performance)