rust-performance
Skill1 starsChanged 40 days agoMITView on GitHub
Rust performance — measure-first methodology, benchmarking (criterion/divan), profiling, concrete optimizations (build config, allocations, hashing, type sizes, iterators), and cutting compile times. Use when code is slow, optimizing a hot path, choosing a profiler, or when builds are slow. Triggers: criterion, divan, flamegraph, FxHashMap, LTO, PGO, jemalloc, dhat, compile times, mold, sccache.
12 other projects use a version of this.
Adopted by
Most recently taken up by
- rewrite-rs/skillstheir own version, first seen Nov 29, 2026
- Dankosik/cargo-modernizetheir own version, first seen Nov 29, 2026
- sajaddp/sonjoo-seo-audittheir own version, first seen Nov 29, 2026
- zevarix/rust-coding-standardstheir own version, first seen Nov 29, 2026
- Lu1sDV/skillsmdtheir own version, first seen Nov 27, 2026
- po4yka/rust-skillstheir own version, first seen Nov 2, 2026
Used with
Projects with it also use rust-unsafe-ffi, rust-api-design and 2 more.
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.
botirkhaltaevSkillrust-unsafe-ffi
Master unsafe Rust, FFI, and foreign function interface programming. Use when writing unsafe Rust code with raw pointers, interfacing with C/C++ libraries, creating bindings with bindgen, implementing zero-cost abstractions, working with uninitialized memory, or understanding the safety/unsafety boundary.
Also in 3 projects that use this
adxptivedSkillrust-api-design
Rust API Design guidelines, naming conventions, and best practices. Use when: - User is designing a library, crate, or public APIs - Implementing patterns like Builder, Typestate, or Extension traits - Designing public structures, enums, or traits - Working with common traits (From/Into, Default, AsRef, Debug, Clone) - Applying #[must_use] or #[non_exhaustive] attributes - Restricting trait implementation via Sealed Traits - Formatting naming structures and lifetime designs
Also in 4 projects that use this
DankosikSkillrust-debugging
Causality. Use for an uncertain Rust CLI defect, panic, hang, incorrect output, resource leak, or platform-dependent failure.
Also in 3 projects that use this
codecharmhqSkillrust-error-handling
Use when writing Rust error types, choosing between Result and panic, or when building library error APIs with thiserror/anyhow
Also in 3 projects that use this
Other versions12 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 12
- huiali/rust-skills★ 47same name
- rewrite-rs/skills★ 32same name
- full-stack-skills/rust-skills★ 8same name
- po4yka/rust-skills★ 7same name
- botirkhaltaev/botir-skills★ 4same name
- jscott3201/yet-more-skills★ 4same name
- Lu1sDV/skillsmd★ 2same name
- zevarix/rust-coding-standards★ 2same name
- adxptived/Rust-Skills★ 1same name
- sajaddp/sonjoo-seo-audit★ 1same name
2 more not listed
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.
In this repository42 other files it gives its agents.
- AGENTS.mdAGENTS.md
- addressing-findingsSkill
- auditSkill
- codebase-onboardingSkill
- codex-reviewSkill
- compatibilitySkill
- debuggingSkill
- developSkill
- distributed-racesSkill
- memorySkill
- nix-dev-envSkill
- nix-flakesSkill
- nixosSkill
- nix-packagingSkill
- nix-reviewSkill
- refactoringSkill
- retroSkill
- review-initSkill
- review-rulesSkill
- rust-architecture-reviewSkill
- rust-architectureSkill
- rust-cliSkill
- rust-cloud-nativeSkill
- rust-concurrencySkill
- rust-ecosystemSkill
- rust-embeddedSkill
- rust-errorsSkill
- rust-fintechSkill
- rust-idiomsSkill
- rust-macrosSkill
- rust-mlSkill
- rust-navigationSkill
- rust-ownershipSkill
- rust-pluginsSkill
- rust-reviewSkill
- rust-securitySkill
- rust-testingSkill
- rust-traitsSkill
- rust-unsafeSkill
- rust-webSkill
- specsSkill
- sql-reviewSkill
The file
We split this skill into the rules it gives an agent
4 rules. 0 are common, 3 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 10 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 31
Profile to find the hot spot: Don't optimize where you *think* time goes — measure it (cargo flamegraph, samply, perf.
- Distinctive: line 35
Re-measure: Keep the change only if the benchmark moved.
- Distinctive: line 43
Before touching code, these settings often buy 10–20% with zero source changes (full toml and tradeoffs in optimizing.md):
- Distinctive: line 68
When the profiler points at code, the usual culprits — each with concrete fixes in optimizing.md:
“Common” is measured: kept by at least 6 in 10 of the 10 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
Performance work is a loop: measure → profile → fix the hot spot → re-measure. Most of the craft is not writing clever code — it's refusing to optimize anything you haven't measured. Concrete techniques distilled from the Rust Performance Book are in the sub-files.
When to Use
- Code is too slow and you need to find out why
- Optimizing a known hot path
- Choosing a benchmarking tool or profiler
- Tuning build/compile settings for speed or size
- The edit→compile→run loop is too slow — cutting compile times (compile-times.md)
The discipline: measure, don't guess
Intuition about Rust performance is wrong more often than not — the optimizer, cache effects, and allocation patterns dominate in non-obvious ways. The rule:
- Build in release.
--release(orcargo bench). A debug build is 10–100× slower and tells you nothing about real performance — never benchmark or profile a dev build. - Establish a baseline. Benchmark the current code so you can prove a change helped (benchmarking.md).
- Profile to find the hot spot. Don't optimize where you think time goes — measure it
(
cargo flamegraph,samply,perf; allocation volume won't show in a CPU profile — use a heap profiler,dhat). Optimize the top of the profile, nothing else. - Apply a targeted fix (optimizing.md) — one change at a time.
- Re-measure. Keep the change only if the benchmark moved; revert if not. "Tiny changes in memory layout can cause significant but ephemeral fluctuations" — confirm, don't assume.
Algorithmic complexity beats micro-optimization: an O(n²)→O(n log n) change outweighs any amount of allocation tuning. Fix the algorithm first, then the constants.
Free wins — build configuration
Before touching code, these settings often buy 10–20% with zero source changes (full toml and tradeoffs in optimizing.md):
[profile.release]
lto = "fat" # cross-crate inlining: 10-20%+, slower compile
codegen-units = 1 # more optimization, slower compile
panic = "abort" # smaller/faster, no unwinding# .cargo/config.toml — newer CPU instructions (binary won't run on older CPUs)
[build]
rustflags = ["-C", "target-cpu=native"]The other axis — faster builds, not faster binaries
Everything above tunes the build for a faster runtime binary, at the cost of compile time
(lto, codegen-units = 1). The opposite goal — a faster edit→compile→run loop — is its own
toolkit: switch to a fast linker (mold/lld), tune the dev profile, split a monolith crate so
rustc parallelizes and rebuilds incrementally, and cut monomorphization bloat. Several knobs flip
between the two axes, so keep them straight → compile-times.md.
Where time and memory usually go
When the profiler points at code, the usual culprits — each with concrete fixes in optimizing.md:
| Symptom | Look at |
lots of malloc/free, Vec growth | heap allocations — with_capacity, reuse, smallvec, Box<[T]>, arenas (bumpalo), compact strings; swap the global allocator (jemalloc/mimalloc); find them with dhat |
hashing hot, many HashMap lookups | swap SipHash for FxHashMap/ahash |
big memcpy, large stack frames | type sizes — box large enum variants, smaller ints |
| tight loops with indexing | iterators (often elide bounds checks); autovectorize the hot loop; avoid redundant work |
| release binary already LTO'd, still need more | profile-guided optimization (PGO); #[cold] on slow paths |
| slow stdout / many small reads or writes | I/O — buffer (BufReader/BufWriter), lock stdout once, read_until |
Boundaries
- Correctness tests for the code you're optimizing →
rust-testing. Performance changes are exactly when a regression test pays off. - Safe SIMD (autovectorization,
std::simd,wide/pulp) is covered here.get_unchecked, architecture-specific intrinsics (std::arch,target_feature) and otherunsafespeedups →rust-unsafe; reach for them only after the safe options and with a benchmark proving the win.
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.

