Rust Performance Analyzer
by vanyastaff
Analyzes Rust code for performance bottlenecks, memory inefficiencies, and optimization opportunities. Use when discussing performance, slow code, memory usage, profiling, benchmarks, or optimization.
Skill Details
Repository Files
1 file in this skill directory
name: rust-performance-analyzer description: Analyzes Rust code for performance bottlenecks, memory inefficiencies, and optimization opportunities. Use when discussing performance, slow code, memory usage, profiling, benchmarks, or optimization.
Rust Performance Analyzer
Expert skill for analyzing and optimizing Rust application performance.
When to Use
Activate this skill when the user:
- Mentions "slow", "performance", "optimize", "bottleneck"
- Asks about memory usage or allocation patterns
- Wants to profile or benchmark code
- Reports laggy UI or frame drops
- Discusses cache efficiency or data layout
Analysis Process
1. Identify Hot Paths
Look for:
- Frequent allocations (
Vec::new(),String::new()in loops) - Unnecessary cloning (
.clone()where borrow would work) - Hash map lookups in tight loops
- Box/Arc indirection overhead
2. Memory Layout Analysis
Check:
- Struct field ordering (largest first for alignment)
- Use of
#[repr(C)]where needed - Option niche optimization usage
- Cache line friendliness
3. Concurrency Patterns
Evaluate:
- Lock contention (
Mutex,RwLockusage) - parking_lot vs std sync primitives
- Atomic operations appropriateness
- Send/Sync bounds efficiency
4. FLUI-Specific Patterns
Focus on:
- Signal update frequency
- Rebuild triggering patterns
- Layout phase efficiency
- Paint layer caching
Optimization Techniques
Allocation Reduction
// Bad: Allocates on every call
fn process(items: &[Item]) -> Vec<ProcessedItem> {
items.iter().map(|i| process_one(i)).collect()
}
// Good: Reuse buffer
fn process_into(items: &[Item], buffer: &mut Vec<ProcessedItem>) {
buffer.clear();
buffer.extend(items.iter().map(|i| process_one(i)));
}
Clone Elimination
// Bad: Unnecessary clone
let data = self.data.clone();
process(&data);
// Good: Borrow directly
process(&self.data);
Interior Mutability
// Use RefCell/Cell for single-threaded
// Use parking_lot::{Mutex, RwLock} for multi-threaded
// Use atomics for simple counters/flags
Profiling Commands
# Build with debug symbols
cargo build --release
# CPU profiling (requires cargo-flamegraph)
cargo flamegraph --example <name>
# Memory profiling
RUSTFLAGS="-Z sanitizer=address" cargo +nightly run --example <name>
# Benchmarking
cargo bench
Output Format
Provide:
- Identified Issues: List of performance problems found
- Impact Assessment: Severity (High/Medium/Low)
- Optimization Suggestions: Specific code changes
- Metrics: Before/after estimates where possible
Related Skills
Mermaid Diagrams
Comprehensive guide for creating software diagrams using Mermaid syntax. Use when users need to create, visualize, or document software through diagrams including class diagrams (domain modeling, object-oriented design), sequence diagrams (application flows, API interactions, code execution), flowcharts (processes, algorithms, user journeys), entity relationship diagrams (database schemas), C4 architecture diagrams (system context, containers, components), state diagrams, git graphs, pie charts,
Matlab
MATLAB and GNU Octave numerical computing for matrix operations, data analysis, visualization, and scientific computing. Use when writing MATLAB/Octave scripts for linear algebra, signal processing, image processing, differential equations, optimization, statistics, or creating scientific visualizations. Also use when the user needs help with MATLAB syntax, functions, or wants to convert between MATLAB and Python code. Scripts can be executed with MATLAB or the open-source GNU Octave interpreter
Dask
Distributed computing for larger-than-RAM pandas/NumPy workflows. Use when you need to scale existing pandas/NumPy code beyond memory or across clusters. Best for parallel file processing, distributed ML, integration with existing pandas code. For out-of-core analytics on single machine use vaex; for in-memory speed use polars.
Consult Zai
Compare z.ai GLM 4.7 and code-searcher responses for comprehensive dual-AI code analysis. Use when you need multiple AI perspectives on code questions.
Writing Effective Prompts
Structure Claude prompts for clarity and better results using roles, explicit instructions, context, positive framing, and strategic organization. Use when crafting prompts for complex tasks, long documents, tool workflows, or code generation.
Analyze Performance
Establish performance baselines and detect regressions using flamegraph analysis. Use when optimizing performance-critical code, investigating performance issues, or before creating commits with performance-sensitive changes.
Flowchart Creator
Create HTML flowcharts and process diagrams with decision trees, color-coded stages, arrows, and swimlanes. Use when users request flowcharts, process diagrams, workflow visualizations, or decision trees.
Bio Reporting Rmarkdown Reports
Create reproducible bioinformatics analysis reports with R Markdown including code, results, and visualizations in HTML, PDF, or Word format. Use when generating analysis reports with RMarkdown.
Desmos Graphing
Create interactive Desmos graphs in Obsidian using desmos-graph code blocks. Use when visualizing functions, parametric curves, inequalities, or mathematical relationships with customizable styling and settings.
Performance
Rendimiento & Optimización - Atoll Tourisme. Use when optimizing performance or profiling code.
