m10-performance_skill

This skill helps you optimize Rust performance by guiding measurement, profiling, and design choices to reduce allocations, improve cache, and parallelize.
  • Shell

565

GitHub Stars

1

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill zhanghandong/rust-skills --skill m10-performance

  • SKILL.md4.1 KB

Overview

This skill provides targeted guidance for performance optimization in Rust projects, focusing on measurement-first approaches and practical implementation choices. It helps you decide if optimization is worth the cost, where to focus (algorithm, data structure, allocation, cache, parallelism), and which tools to use for profiling and benchmarking.

How this skill works

The skill inspects performance concerns by guiding you to measure first with profiling and benchmarks, then trace requirements up to domain constraints and down to concrete implementation changes. It maps goals (reduce allocations, improve cache, parallelize, avoid copies) to specific design choices and Rust techniques like with_capacity, SmallVec, Rayon, and zero-copy patterns.

When to use it

  • When a measured hotspot affects user-facing latency or throughput
  • During performance regressions discovered by CI or benchmarks
  • Before introducing complex optimizations that increase maintenance cost
  • When planning capacity for throughput or memory-constrained deployments
  • When choosing data layout or concurrency model for a hot path

Best practices

  • Profile first: use perf, flamegraph, or heaptrack to find real hotspots
  • Benchmark in release mode with criterion or cargo bench for statistical confidence
  • Prioritize algorithm and data structure changes before micro-optimizations
  • Reduce allocations via pre-allocation, object pools, and avoiding hidden clones
  • Prefer contiguous layouts (Vec/SmallVec) and batch operations for cache efficiency

Example use cases

  • Identify a CPU hotspot with flamegraph, then replace an O(n^2) algorithm with an O(n log n) approach
  • Reduce GC/alloc pressure by switching from boxed nodes to SmallVec or inline arrays
  • Improve throughput by parallelizing a CPU-heavy loop using rayon
  • Fix latency spikes by measuring tail latencies and trimming allocation spikes
  • Choose Vec over HashMap for small collections to improve cache locality

FAQ

No. Always measure first. Optimizing without data risks wasted effort and regressions.

Which gives the biggest wins?

Algorithmic improvements often yield the largest gains (10x–1000x). Data structure and allocation changes are next.

When to use SIMD or parallelism?

Use SIMD/parallelism after ensuring algorithm and data layout are efficient; they help when CPU-bound hotspots remain.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational
m10-performance skill by zhanghandong/rust-skills | VeilStrat