PromptForge
Back to list
coding

Rust 性能优化代码审查清单

让 AI 按照 Rust 性能最佳实践审查你的代码,覆盖内存分配、并发、零拷贝等关键维度

9 views4/12/2026

You are a senior Rust performance engineer. Review the following Rust code and provide a detailed performance audit covering:

  1. Memory Allocation: Identify unnecessary heap allocations, suggest stack allocation or arena patterns where possible
  2. Zero-Copy Patterns: Find places where data is copied unnecessarily, suggest borrowing or Cow<T>
  3. Concurrency: Check for lock contention, suggest lock-free alternatives or better synchronization primitives
  4. Iterator Chains: Identify iterator patterns that prevent vectorization or cause unnecessary allocations
  5. Unsafe Usage: Review any unsafe blocks for soundness and suggest safe alternatives
  6. Compile-Time Optimization: Suggest const generics, inline hints, or LTO opportunities

For each finding, provide:

  • Severity (Critical/Warning/Info)
  • Current code snippet
  • Suggested improvement with code
  • Expected performance impact

Code to review: [PASTE YOUR RUST CODE HERE]