rust-performance

Profile Rust code with perf, flamegraph, and heaptrack to diagnose performance bottlenecks.

44|7|Updated Jan 22, 2026
One-click install
npx skills add https://github.com/huiali/rust-skills --skill rust-performance-huiali
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rust-performance
Source: https://github.com/huiali/rust-skills/tree/main/.codex/skills/rust-performance
Command: npx skills add https://github.com/huiali/rust-skills --skill rust-performance-huiali

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill helps you identify and fix performance bottlenecks in your Rust code, ensuring your applications run as fast and efficiently as possible.

Core Features & Use Cases

  • Profiling and Benchmarking: Use tools like perf, flamegraph, and cargo bench to pinpoint slow code sections.
  • Optimization Techniques: Apply strategies like pre-allocation, avoiding unnecessary clones, batch operations, and cache-aware data structures.
  • Advanced Scenarios: Address issues like false sharing, lock contention, and NUMA awareness in multi-threaded applications.
  • Use Case: Your Rust web server is experiencing high latency under load. Use this Skill to profile the request handling, identify the slow path (e.g., database access or serialization), and apply optimizations like connection pooling or more efficient data serialization.

Quick Start

Use the rust-performance skill to profile the attached Rust project and identify the top 3 performance bottlenecks.

Frequently Asked Questions about rust-performance

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I profile Rust code to find performance bottlenecks?

You can profile Rust code using tools like perf, flamegraph, and cargo bench to pinpoint slow code sections. These tools help identify memory allocation issues and measure execution times for targeted optimization.

What is false sharing in Rust multi-threading and how do I fix it?

False sharing is a concurrency issue where threads modify independent variables on the same cache line, causing lock contention. You fix it by applying cache-aware data structures and memory allocation strategies to separate data accesses.

What's the best way to reduce latency in a Rust web server under load?

The best way to reduce latency in a Rust web server is to profile request handling to identify slow paths like database access or serialization. Apply optimizations including connection pooling, efficient data serialization, and pre-allocation to improve throughput.

Can I use cargo bench to benchmark Rust applications for memory allocation issues?

Yes, cargo bench is used for benchmarking Rust applications to measure execution times, while heaptrack specifically identifies memory allocation issues. Combining them provides a comprehensive view of performance and heap usage for optimization.

Do I need to understand Rust's memory model to optimize concurrency and cache performance?

Yes, understanding Rust's memory model and concurrency primitives is required to optimize cache performance and address multi-threading concerns. This knowledge enables you to apply cache-aware data structures and resolve lock contention effectively.

When should I apply SIMD and cache optimization in Rust?

You should apply SIMD and cache optimization in Rust when targeting data-level parallelism and memory access patterns to improve application throughput and reduce latency. These techniques address advanced performance issues in compute-bound or memory-bound tasks.