mcpField
R
rust-optimise

rust-optimise

github.com/pproenca开发21852 次安装11 周前更新
代码仓库

关于 rust-optimise

面向 Rust 开发者的性能优化指南,按影响优先级整理 8 类规则,涵盖内存、借用、异步和算法等实践。适用于优化、审查及编写 Rust 代码。

主要功能

  1. 01涵盖 8 类优化主题
  2. 02按影响优先级排序规则
  3. 03减少内存分配与克隆
  4. 04指导异步与并发实践
  5. 05包含算法和迭代器建议

适用场景

  1. 01排查 Rust 性能瓶颈
  2. 02减少代码中的不必要分配
  3. 03选择适合的数据结构
  4. 04审查异步代码中的性能问题

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/pproenca/dot-skills --skill rust-optimise

安装后在 Claude Code 中输入/rust-optimise确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

AGENTS.md
README.md
metadata.json
assets/templates/
_template.md
references/
_sections.md
algo-avoid-nested-loops-for-lookup.md
algo-use-binary-search-for-sorted-data.md
algo-use-chunks-for-batch-processing.md
algo-use-select-nth-unstable-for-partial-sort.md
algo-use-sort-unstable-when-order-irrelevant.md
async-avoid-blocking-in-async-context.md
async-avoid-holding-lock-across-await.md
async-minimize-lock-scope.md
async-use-buffered-for-bounded-concurrency.md
async-use-join-for-concurrent-futures.md
async-use-rwlock-over-mutex-for-read-heavy.md
comp-avoid-repeated-parsing-of-static-data.md
comp-prefer-static-dispatch.md
comp-reduce-monomorphization-bloat.md
comp-use-const-for-compile-time-computation.md
comp-use-const-generics-for-array-sizes.md
ds-use-btreemap-for-sorted-iteration.md
ds-use-entry-api-for-conditional-insert.md
ds-use-hashmap-for-key-lookup.md
ds-use-hashset-for-membership.md
ds-use-vecdeque-for-queue-operations.md
iter-chain-instead-of-intermediate-collect.md
iter-use-extend-for-bulk-append.md
iter-use-filter-map-for-combined-operations.md
iter-use-flat-map-for-nested-iteration.md

详细介绍

Rust 性能优化最佳实践

Rust 应用的性能优化指南。包含 8 个类别中的 42 条规则,按影响从关键(内存分配、所有权)到渐进式(微优化)排序。

适用场景

  • 优化 Rust 代码的性能或减少内存分配
  • 选择具有最优算法复杂度的数据结构
  • 使用迭代器,避免不必要的中间分配
  • 使用 Tokio 或其他运行时编写异步代码
  • 分析热点路径并消除性能瓶颈
  • 检查代码中的性能反模式

按优先级划分的规则类别

优先级类别影响前缀
1内存分配严重mem-
2所有权与借用严重own-
3数据结构选择高ds-
4迭代器与集合模式高iter-
5异步与并发中高async-
6算法复杂度中algo-
7编译时优化中comp-
8微优化低micro-

快速参考

1. 内存分配(严重)
2. 所有权与借用(严重)
3. 数据结构选择(高)
4. 迭代器与集合模式(高)
5. 异步与并发(中高)
6. 算法复杂度(中)
7. 编译时优化(中)
8. 微优化(低)

参考资料

  1. https://nnethercote.github.io/perf-book/
  2. https://rust-lang.github.io/api-guidelines/
  3. https://doc.rust-lang.org/nomicon/
  4. https://tokio.rs/tokio/tutorial

相关技能

  • 关于惯用模式、架构和代码组织,请参阅 rust-refactor 技能

评论

支持 Markdown