用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/caarlos0/dotfiles --skill rust-performance命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
| name | rust-performance |
| description | Profile and optimize Rust CPU, memory, I/O, async, and build performance with representative benchmarks. |
Profile first, then change one measured bottleneck. Report the workload, tool, target, toolchain, build profile, and before/after values.
Use optimized code with symbols:
[profile.profiling]
inherits = "release"
debug = "line-tables-only"
Use Criterion for microbenchmarks and std::hint::black_box only where the
compiler could fold inputs or remove results. For CPU profiles use the
repository's profiler, samply, perf, Instruments, or cargo flamegraph.
Use DHAT or an allocation profiler when CPU samples point to allocation.
Vec::with_capacity, String::with_capacity, and
HashMap::with_capacity.clone_from when replacing an existing value can reuse its allocation.Cow at boundaries where most callers borrow and few need ownership.
Do not spread it through APIs without evidence; it adds branching and type
complexity.SmallVec and other inline collections help only when the observed length
distribution usually fits inline. Their inline storage increases value and
stack size.size_of, -Zprint-type-sizes, or a type-size
tool. Box a rare large enum variant only when shrinking the common value
improves the workload.For maps, use the entry API to avoid duplicate lookups and reserve capacity when the size is known. Alternative hashers trade collision resistance, dependencies, and portability for throughput; use them only for trusted keys after representative key-distribution benchmarks.
size_hint for custom iterators consumed by collect
or extend.collect when the result is immediately iterated once; keep the chain
lazy. Collect when ownership, sorting, indexing, or reuse requires it.String, Vec<u8>, or bytes::BytesMut buffers instead of formatting
or allocating per item. Work with &[u8] for genuinely byte-oriented data;
do not discard Unicode or path semantics for speed.Path/OsStr values native. Avoid string conversion solely for
comparison or joining.Use BufReader/BufWriter for repeated small operations and choose capacity
from observed request sizes. Batch writes and reuse read buffers. Preserve
partial-write handling, flush errors, EOF behavior, and output ordering; a
faster path that changes them is incorrect.
spawn_blocking for bounded blocking work and
Rayon or a dedicated pool for sustained CPU parallelism.std::sync::Mutex when the guard never crosses .await; use an async
mutex only when it must. Profile contention before replacing either.mpsc,
oneshot, watch, or broadcast from message semantics, not benchmark
folklore.select! branches before batching or
buffering. Work discarded on cancellation is still cost.Invoke runtime-process-debugging for process, pipe, EOF, child-lifecycle, or
shutdown stalls.
Benchmark lto, codegen-units, opt-level, panic strategy, allocator, PGO,
and linker changes separately. target-cpu=native is valid only for fixed
deployment hardware; it makes distributed artifacts non-portable.
Before adding SIMD or unsafe, verify the hot instruction sequence and whether
the compiler already removed bounds checks or vectorized it. Prefer safe loop
shapes first. Every unsafe optimization needs a precise invariant, tests that
exercise it, and a measured win over the safe version.
Use a focused Criterion benchmark, allocation guard, or compile-time size assertion only for the invariant that matters. Keep wall-time on shared CI advisory unless hardware and variance are controlled. Pin the Rust toolchain when compiler code generation affects the comparison.
rust-specialist takes precedence for correctness, safety, and API design.code-review checks a completed diff. When invoked from code-review, do not
invoke it again.code-simplifier runs after the gain is proven and preserves measured
behavior.runtime-process-debugging owns process and lifecycle stalls.Correctness and safety override performance.