rust-performance
Skill4 starsChanged 3 months agoApache-2.0View on GitHub
Diagnose and improve Rust runtime speed, memory use, binary size, and compile times with a measurement-first workflow distilled from The Rust Performance Book. Use when profiling hot paths, tuning build settings, reducing allocations, improving I/O, inlining decisions, or fixing slow Rust builds.
We split this skill into the rules it gives an agent
34 rules. 0 are common, 24 are distinctive, and 10 are very specific to this project.
0
Common
Most of the 6 edited versions we read keep these.
24
Distinctive
This author's own choices. Worth a look.
10
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Use this skill for Rust optimization work that needs disciplined measurement, targeted changes, and explicit trade-offs, following the …
- Distinctive: line 30
Use benchmarks for comparisons and regressions.
- Distinctive: line 31
Use profilers for hotspots.
- Distinctive: line 32
Use heap profilers when allocation rate or peak memory looks suspicious.
- Distinctive: line 33
Use compile-time tools when build speed is the problem.
- Very specific: line 43
Start with references/build-configuration.md and references/compile-times.md.
- Distinctive: line 47
Consider a custom dev profile
- Distinctive: line 48
Avoid judging runtime from dev builds
- Very specific: line 52
Start with references/measurement.md, then follow the hotspot.
- Very specific: line 62
Look for clone, to_owned, format!, growing Vec/String, and line-by-line allocation
- Distinctive: line 69
Consider alternative hashers only when HashDoS is not a concern
- Distinctive: line 79
Avoid heavy formatting or logging work on cold paths
- Distinctive: line 86
Check linker, debuginfo, macro expansion, and LLVM IR bloat
- Distinctive: line 94
Check contention, allocator pressure, and memory locality first
- Very specific: line 100
Consider #[inline] or #[inline(always)] for small hot functions
- Very specific: line 101
Use #[cold] to outline error paths
- Distinctive: line 118
Do not optimize before establishing a measurement loop.
- Distinctive: line 119
Prefer release builds for runtime conclusions.
- Distinctive: line 121
Prefer simple, idiomatic wins before advanced tricks.
- Very specific: line 122
Treat unsafe, PGO, SIMD, manual hashing tricks, and aggressive inlining as late-stage tools.
- Distinctive: line 123
Call out trade-offs in speed, memory, compile time, debuggability, portability, and clarity.
- Distinctive: line 124
Keep non-obvious optimizations documented with the reason they help.
- Distinctive: line 130
Always establish a baseline before making changes:
- Very specific: line 131
Use criterion.rs for statistical benchmarking
- Distinctive: line 134
Use wall-time, cycles, or instruction counts as appropriate
- Distinctive: line 152
Prefer stack allocation when possible
- Distinctive: line 153
Use object pools for frequent allocations
- Distinctive: line 155
Consider custom allocators for specific workloads
- Very specific: line 159
Use panic = "abort" in Cargo.toml
- Very specific: line 162
Remove unused dependencies with cargo tree
- Very specific: line 163
Use #![no_std] when appropriate for embedded
- Distinctive: line 169
Use incremental compilation during development
- Distinctive: line 171
Consider splitting large crates
- Distinctive: line 178
Consider allocator tuning for your workload
“Common” is measured: kept by at least 6 in 10 of the 6 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Rust Performance
Use this skill for Rust optimization work that needs disciplined measurement, targeted changes, and explicit trade-offs, following the methodologies from The Rust Performance Book (https://nnethercote.github.io/perf-book/).
When to Use This Skill
- Runtime performance is too slow in
--release - Memory usage, allocation rate, or
memcpytraffic is high - Binary size needs to shrink
- Compile times are slow or regressing
- Profilers show confusing stacks, symbols, or hotspots
HashMap, iterators, I/O, logging, or synchronization appear hot- Inlining decisions need tuning (function call overhead is hot)
- Machine code inspection needed for bounds checks or missed vectorization
- You need a Rust-specific optimization workflow instead of generic advice
Core Workflow
- Confirm the goal: runtime, memory, binary size, compile times, or a mix.
- Confirm build context before drawing conclusions.
- Runtime claims should come from
--release. - Profiling builds should usually keep line info.
- Build complaints may be caused by debuginfo, linker choice, or profile settings.
- Runtime claims should come from
- Measure before changing code.
- Use benchmarks for comparisons and regressions.
- Use profilers for hotspots.
- Use heap profilers when allocation rate or peak memory looks suspicious.
- Use compile-time tools when build speed is the problem.
- Map the symptom to the most likely area.
- Make the smallest high-confidence change first.
- Re-measure after every change.
- Capture fragile wins with comments, tests, or benchmark checks.
Symptom Triage
Slow in dev, acceptable in release
Start with references/build-configuration.md and references/compile-times.md.
- Check debuginfo level
- Check linker choice
- Consider a custom dev profile
- Avoid judging runtime from dev builds
Slow in release too
Start with references/measurement.md, then follow the hotspot.
- Hot CPU path -> measurement, collections, layout, or build tuning
- Hot call overhead -> inlining/build choices, but only after profiling
- Hot bounds or iterator adapters -> collections and iterators
High allocation rate or memory churn
Start with references/allocations-layout.md.
- Look for
clone,to_owned,format!, growingVec/String, and line-by-line allocation - Reuse buffers and collections before reaching for exotic changes
HashMap or hashing is hot
Start with references/collections-iterators.md.
- Consider alternative hashers only when HashDoS is not a concern
- Measure hasher changes on real workloads
Slow file or terminal processing
Start with references/io-debugging.md.
- Lock stdout for repeated writes
- Buffer reads and writes
- Reuse line buffers
- Avoid heavy formatting or logging work on cold paths
Builds are slow
Start with references/compile-times.md and references/build-configuration.md.
- Use
cargo build --timings - Check linker, debuginfo, macro expansion, and LLVM IR bloat
- Reduce unnecessary monomorphization
Multi-core machine is underused
Start with references/parallelism.md.
- Confirm the bottleneck is worth parallelizing
- Check contention, allocator pressure, and memory locality first
Function call overhead is hot
Start with references/inlining-machine-code.md.
- Consider
#[inline]or#[inline(always)]for small hot functions - Use
#[cold]to outline error paths - Inspect generated machine code with Compiler Explorer or
cargo-show-asm
Reference Map
references/measurement.md- benchmarking, profiling, profiler hygiene, specific toolsreferences/build-configuration.md- release settings, LTO, allocators, CPU tuning, binary size, faster buildsreferences/allocations-layout.md- heap churn, type size, wrapper overhead, data layout, SmallVec/ThinVecreferences/collections-iterators.md- iterator costs, std type behavior, hashing trade-offs, alternative hashersreferences/io-debugging.md- buffering, line handling, logging, assertion overheadreferences/inlining-machine-code.md- inline attributes, cold, outlining, machine code inspection, SIMDreferences/parallelism.md- thread-level parallelism and synchronization trade-offsreferences/compile-times.md- timings, macros, monomorphization, linker winsreferences/general-principles.md- optimization mindset, guardrails, Clippy perf lints
Guardrails
- Do not optimize before establishing a measurement loop.
- Prefer release builds for runtime conclusions.
- Change one variable at a time when benchmarking.
- Prefer simple, idiomatic wins before advanced tricks.
- Treat
unsafe, PGO, SIMD, manual hashing tricks, and aggressive inlining as late-stage tools. - Call out trade-offs in speed, memory, compile time, debuggability, portability, and clarity.
- Keep non-obvious optimizations documented with the reason they help.
Key Techniques from The Rust Performance Book
Measurement First
Always establish a baseline before making changes:
- Use criterion.rs for statistical benchmarking
- Profile with tools like perf, Valgrind, or VTune
- Measure in
--releasemode for runtime conclusions - Use wall-time, cycles, or instruction counts as appropriate
Build Configuration
Optimize Cargo.toml profiles:
[profile.release]
opt-level = 3
lto = "thin" # or "fat" for maximum optimization
codegen-units = 1 # Better optimization, slower builds
incremental = false # Faster release builds
debuginfo = 0 # Strip debug info for smaller binaries
panic = "abort" # Smaller binaries, faster unwindingMemory Optimization
- Reuse buffers and allocations
- Prefer stack allocation when possible
- Use object pools for frequent allocations
- Minimize copying with slices and references
- Consider custom allocators for specific workloads
Binary Size Reduction
- Use
panic = "abort"in Cargo.toml - Enable LTO (Link Time Optimization)
- Strip symbols with
striporsstrip - Remove unused dependencies with
cargo tree - Use
#![no_std]when appropriate for embedded
Compile Time Optimization
- Reduce monomorphization with trait objects
- Limit generic code in hot paths
- Use incremental compilation during development
- Optimize build scripts and procedural macros
- Consider splitting large crates
CPU-Specific Optimizations
- Target specific CPU architectures:
RUSTFLAGS="-C target-cpu=native" - Enable SIMD with portable packed simd or platform intrinsics
- Profile-guided optimization (PGO) for hot paths
- Consider allocator tuning for your workload
Practical Defaults
- For runtime work: benchmark, profile, then optimize the hottest path.
- For allocation work: use a heap profiler and reuse buffers before redesigning architecture.
- For build work: fix link/debuginfo/profile settings before rewriting code.
- For container or CLI size work: review profile settings,
panic = "abort", and stripping. - For synchronization concerns: benchmark the actual primitive and contention pattern instead of assuming.
Key Tools
| Tool | Purpose |
criterion / divan | Statistical benchmarking |
hyperfine | CLI program benchmarking |
perf / samply | Sampling profilers (CPU hotspots) |
DHAT / dhat-rs | Heap allocation profiling |
Cachegrind | Instruction counts, cache simulation |
Coz | Causal profiling (optimization potential) |
cargo-show-asm | View generated assembly |
cargo llvm-lines | LLVM IR bloat diagnosis |
cargo build --timings | Build parallelism visualization |
cargo-wizard | Interactive build config chooser |
| Compiler Explorer | Online assembly inspection |
Other versions7 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 7
- huiali/rust-skills★ 47same name
- full-stack-skills/rust-skills★ 8same name
- jscott3201/yet-more-skills★ 4same name
- Lu1sDV/skillsmd★ 2same name
- po4yka/rust-skills★ 2same name
- adxptived/Rust-Skills★ 1same name
- Dankosik/rust-cli-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
Used alongsideProjects with it also use rust-cli.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
tumfSkillrust-cli
Design and implementation guidance for maintainable Rust CLIs with strong ergonomics, machine-friendly behavior, testable structure, and release automation. Use when creating or refactoring a Rust command-line tool, choosing crates like clap/anyhow/tracing/serde_json, improving command UX, adding JSON output, tightening test/release workflows, or making an existing CLI safer for agents and automation.
Also in 3 projects that use this
In this repository80 other files it gives its agents.
- a11y-accessibility-designSkill
- agentic-ui-patternsSkill
- ai-native-ui-designSkill
- ai-ui-anti-patternsSkill
- ai-ui-heuristicsSkill
- calm-technology-uiSkill
- conversion-growth-designSkill
- cross-platform-designSkill
- dark-mode-designSkill
- data-visualizationSkill
- design-systemsSkill
- design-thinking-processSkill
- error-empty-statesSkill
- ethical-design-patternsSkill
- form-uxSkill
- information-architectureSkill
- interaction-design-patternsSkill
- internationalization-uiSkill
- mobile-touch-designSkill
- modal-classes-lifecycleSkill
- modal-container-imagesSkill
- modal-dicts-queuesSkill
- modal-endpointsSkill
- modal-fundamentalsSkill
- modal-gpu-computeSkill
- modal-networkingSkill
- modal-observabilitySkill
- modal-parallel-executionSkill
- modal-sandboxesSkill
- modal-scaling-performanceSkill
- modal-schedulingSkill
- modal-secretsSkill
- modal-serversSkill
- modal-storageSkill
- modal-web-servingSkill
- modal-workspace-adminSkill
- motion-design-principlesSkill
- notifications-permissionsSkill
- onboarding-uxSkill
- rust-api-designSkill
- rust-async-programmingSkill
- rust-cargo-masterySkill
- rust-cli-applicationsSkill
- rust-clippy-lintsSkill
- rust-closures-iteratorsSkill
- rust-compiler-internalsSkill
- rust-concurrencySkill
- rust-design-patternsSkill
- rust-editionsSkill
- rust-embeddedSkill
- rust-error-handlingSkill
- rust-game-developmentSkill
- rust-lifetimes-borrowingSkill
- rust-macrosSkill
- rust-rustdocSkill
- rust-rustup-toolchainSkill
- rust-smart-pointersSkill
- rust-testing-benchmarkingSkill
- rust-type-systemSkill
- rust-unsafe-ffiSkill
- The first 60 shown.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

