Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsCommunityBlog
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

Back to skills

Rust Performance

ASecurity

Use when Rust code is slow, allocates too much, regresses latency or throughput, or has bloated binaries and long compile times. Covers the evidence pipeline (workload contract, reproducible baseline, profiling, single-cause change, re-measurement), optimization priority from algorithm down to SIMD, and concrete fixes for allocation, cache, false sharing, lock contention, and NUMA. Triggers: cargo bench, Criterion, samply, perf, flamegraph, heaptrack, DHAT, cargo-bloat, p99, hot path.

2 stars
0 votes
0 copies
0 views
Added 9/19/2026
ai-agentsrustgonodeperformance

Security Analysis

A100/100

Scanned 9/19/2026

Install to Claude Code

$npx -y skills add Lu1sDV/skillsmd --skill rust-performance --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Rust Performance?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Rust Performance
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/lu1sdv-rust-performance/badge)](https://www.skillsdirectory.com/skills/lu1sdv-rust-performance)

More formats (shields.io, HTML) on the badges page.

Download Zip
Files
SKILL.md
---
name: rust-performance
description: >
  Use when Rust code is slow, allocates too much, regresses latency or
  throughput, or has bloated binaries and long compile times. Covers the
  evidence pipeline (workload contract, reproducible baseline, profiling,
  single-cause change, re-measurement), optimization priority from algorithm
  down to SIMD, and concrete fixes for allocation, cache, false sharing, lock
  contention, and NUMA. Triggers: cargo bench, Criterion, samply, perf,
  flamegraph, heaptrack, DHAT, cargo-bloat, p99, hot path.
---

# Rust Performance

Optimize from evidence. Define the user-visible metric, reproduce the workload,
establish a stable baseline, profile the dominant cost, change one cause, and
prove both correctness and improvement.

## Quick Reference

Optimization priority — always fix the highest rung first:

```text
1. Algorithm choice    10x-1000x   biggest impact
2. Data structure       2x-10x
3. Reduce allocations   2x-5x
4. Cache locality       1.5x-3x
5. SIMD / parallelism   2x-8x
```

Pick the measurement layer before touching code:

| Question | Tool |
|---|---|
| Is a pure operation faster? | Criterion / Divan microbenchmark |
| Did instruction-level cost change? | iai-callgrind (deterministic, CI-friendly) |
| Where is CPU time spent? | samply, `cargo flamegraph`, perf, Instruments |
| Where are allocations retained? | DHAT, heaptrack, allocator metrics |
| Why is the binary large? | `cargo bloat`, feature inspection |
| What drives compile time? | `cargo build --timings`, `cargo llvm-lines` |
| Does the service meet its SLO? | representative load test + observability |

A microbenchmark never proves end-to-end latency, overload behavior, or memory
bounds. Match the tool to the question.

## Workflow

### 1. Define the performance contract

Record workload, dataset, inputs, concurrency, platform, CPU/memory limits,
toolchain, target, features, allocator, build profile, warm-up, cache state,
and the success metric. Separate throughput from p50/p95/p99 latency, and
steady state from startup/shutdown.

Do not optimize debug builds or synthetic inputs unless they are the real
problem.

### 2. Establish a reproducible baseline

- Verify correctness before benchmarking.
- Use release-like settings (opt-level, codegen-units, LTO, panic strategy,
  target-cpu) deliberately and record them.
- Isolate background load, thermal throttling, and noisy shared runners.
- Keep raw samples and variance, not one average.

### 3. Add regression tests before optimizing

**Correctness-first gate**: if the change touches parsing, I/O, or float
formatting, add or extend the regression test *before* benchmarking.

```text
1. BASELINE   cargo test        current behavior pinned
2. TEST       add regression tests for the code you will change
3. OPTIMIZE   change one cause
4. VERIFY     cargo test        correctness preserved
5. BENCHMARK  cargo bench       improvement measured
```

### 4. Profile before editing

Capture a profile under the failing workload with symbols preserved, using the
same optimized artifact you intend to compare. Separate on-CPU work, waiting,
lock contention, I/O, allocation, page faults, and scheduler overhead.

### 5. Optimize the dominant cause

Common wins: algorithmic complexity, fewer passes, batching, avoiding repeated
parsing or allocation, borrowing instead of cloning, data-layout changes,
reduced synchronization, bounded queues, streaming, feature reduction, moving
CPU work off async workers.

Unsafe, custom allocators, SIMD, lock-free structures, and caching are last
resorts — only after simpler changes fall short, and only with documented
invariants plus tests.

### 6. Track memory, size, and build cost

Peak RSS, retained heap, allocation rate, fragmentation, cache growth, buffer
bounds, binary sections, monomorphization, debug info, enabled features, macro
expansion, incremental versus clean compile time.

### 7. Prove the result

Rerun correctness tests and the exact baseline protocol. Report absolute and
relative numbers, variance, hardware/software context, tradeoffs, and any
secondary-metric regression. Add a durable benchmark or budget only when the
environment reliably detects the threshold.

## Hard Rules

- Never benchmark without documenting the build profile.
- Never optimize without a profile showing the dominant cost.
- Never trade correctness or safety for speed: prove invariants with tests.
- Never micro-optimize cold paths or accept <20% wins at the cost of clarity.
- Keep cold paths readable; spend complexity only in verified hot loops.

## Diagnostics: symptom to cause

| Symptom | Likely cause | Fix |
|---|---|---|
| One core at 100%, many atomic RMW ops, more threads = slower | False sharing | `#[repr(align(64))]` per counter |
| Time in lock/unlock, degrades with threads | Lock contention | thread-local sharding, merge at end; DashMap for concurrent writes |
| Scaling stalls on multi-socket | Cross-NUMA access | `numactl --cpunodebind/--membind`, NUMA-aware pools |
| Allocator pressure, many small allocs | Per-item allocation | preallocate, reuse buffers, `SmallVec`, object pooling |
| O(n²) growth in a loop | Repeated concatenation / rehash | `with_capacity`, batch ops, integer keys over strings |
| High LLC misses on linear scans | Pointer chasing / poor layout | SoA instead of AoS, `Vec`/`VecDeque` over `LinkedList` / `Box` chains |

Patterns, code, and expanded triage tables:
[references/optimization-patterns.md](references/optimization-patterns.md).
Tooling, benchmark templates, build profiles, and report format:
[references/measurement-and-profiling.md](references/measurement-and-profiling.md).

## Completion Criteria

- Representative workload and user-visible metric defined.
- Reproducible baseline recorded before the change.
- Dominant cost identified by profile, not guessed.
- Correctness preserved, proven by targeted tests.
- Re-measured under the same protocol; uncertainty and tradeoffs reported.
- Stable regression check added, or the environment's noise floor explained.

## Data Privacy

This skill does not collect, transmit, or store data. Profiles, heap dumps,
symbols, and benchmark datasets can contain sensitive information — confirm
storage and upload policy before sharing them.

Attribution

Lu1sDVLu1sDV
View sourceMore from Lu1sDV →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Caveman

Ultra-compressed communication mode. Cuts token usage ~75% by speaking like caveman while keeping full technical accuracy. Supports intensity levels: lite, full (default), ultra, wenyan-lite, wenyan-full, wenyan-ultra. Use when user says "caveman mode", "talk like caveman", "use caveman", "less tokens", "be brief", or invokes /caveman. Also auto-triggers when token efficiency is requested.

1023331 votes

Hyperplan

Adversarial multi-agent planning skill. Self-orchestrates 5 hostile category members (unspecified-low, unspecified-high, deep, ultrabrain, artistry) via team-mode for ruthless cross-critique debate, distills only the defensible insights, then MANDATORILY hands the distilled insight bundle to the `plan` agent for executable plan formalization. Use when planning needs maximum rigor and surfacing of weak assumptions, blind spots, and over-engineering. Triggers: 'hyperplan', 'hpp', '/hyperplan', ...

686011 votes

Mcp Code Execution

Routes multi-tool workflows through MCP servers for large datasets and pipelines. Use when Bash tool overhead is limiting throughput on data-heavy tasks.

3331 votes

catchup

Recovers prior coding-agent session context by running `catchup <agent> --since-compact`, which extracts a clean summary of a previous Codex, Claude Code, Antigravity, OpenCode, or Pi Agent session. Use when the user says "catch up", "what did the last session do", "get me up to speed", "I switched agents", or asks to recover/summarize a previous session before continuing. Do NOT use for the current conversation, git history, or any non-agent log.

611 votes

math-skill

A comprehensive mathematical reasoning skill for AI assistants — handles arithmetic to research-level problems with rigorous step-by-step reasoning, systematic verification, and transparent uncertainty handling

381 votes
View all in ai-agents →