Back to Skills

m10-performance

CRITICAL: Use for performance optimization. Triggers: performance, optimization, benchmark, profiling, flamegraph, criterion, slow, fast, allocation, cache, SIMD, make it faster, 性能优化, 基准测试

1,376stars110forksUpdated 8/6/2026

Security Assessment

Safe(96/100)
Security Score96/100

About m10-performance

This skill is the performance-optimization reference (module m10, "Layer 2: Design Choices") from the actionbook "rust-skills" set. Its central message is discipline: measure before optimizing, know the acceptable performance target, and weigh added complexity against gains. It is designed to steer developers away from premature or misdirected optimization and toward changes with the highest payoff.

The SKILL.md presents an optimization-priority ladder (algorithm choice for 10x–1000x, then data structures, allocation reduction, cache optimization, and SIMD/parallelism), decision tables mapping goals to techniques such as `Vec::with_capacity`, `Cow<T>`, `SmallVec`, and rayon, plus common-mistake and anti-pattern tables. A companion `patterns/optimization-guide.md` expands into profiling tooling (flamegraph, heaptrack, criterion, cachegrind), allocation and buffer reuse, collection selection, string and iterator optimization, rayon parallelism, memory-layout and struct-packing tips, async performance pitfalls (avoiding blocking calls, buffered I/O), and release-build Cargo settings such as LTO and codegen-units.

The target users are intermediate-to-advanced Rust developers optimizing real workloads who want a measurement-first methodology and a catalogue of proven techniques. Use cases include reducing allocations on hot paths, choosing cache-friendly data structures, parallelizing with rayon, tuning release profiles, and profiling to find genuine bottlenecks. The profiling commands it lists (installing and running flamegraph, criterion benchmarks, valgrind) are standard, read-oriented developer tooling. Bilingual English/Chinese trigger phrases are included.

FAQ

What is the skill's core principle?

Profile and benchmark before optimizing. It repeatedly stresses measuring actual bottlenecks and only optimizing where the payoff justifies added complexity.

What optimization areas does it prioritize?

In order of typical impact: algorithm choice, data-structure choice, allocation reduction, cache optimization, and SIMD/parallelism.

Which profiling tools does it reference?

flamegraph and perf for CPU, heaptrack for allocations, criterion and cargo bench for benchmarking, and valgrind/cachegrind for cache analysis — all standard read-only developer tooling.

Does it cover async and build-level tuning?

Yes. It warns against blocking calls in async code, recommends buffered async I/O, and documents release-profile settings like lto, codegen-units, panic=abort, and strip.

Is this a library or a guide?

It is a guidance document with example code and shell commands for profiling; it does not run an optimizer for you.

All Files

2 files
patterns/optimization-guide.md6.9 KB
View
SKILL.md4.0 KB
View

Install m10-performance

Download and extract the skill files to your .claude/skills/ directory.

Quick Setup:

  1. Copy the skill folder to .claude/skills/
  2. Claude will automatically detect and use the skill