performance-patterns

Guides performance-sensitive C, Go, Rust, and Zig implementation and code reviews.

Updated Jul 4, 2023
One-click install
npx skills add https://github.com/kohdice/dotfiles --skill performance-patterns-kohdice
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: performance-patterns
Source: https://github.com/kohdice/dotfiles/tree/main/config/agents/skills/performance-patterns
Command: npx skills add https://github.com/kohdice/dotfiles --skill performance-patterns-kohdice

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Writing and reviewing performance-critical code often relies on guesswork, leading to wasted optimization effort on cold paths or missed algorithmic bottlenecks in hot paths. This Skill provides a cost-ordered catalog of performance factors so you apply the right fix at the right severity. ## Core Features & Use Cases - Hot-path-aware analysis: Classifies code as hot, cold, or de-minimis based on call context before recommending any optimization. - Cost-ordered factor catalog: Seven factors ranked by typical impact, from algorithmic complexity and allocations down to language mechanism costs, each tagged with a static or measure evidence tier. - Per-language references: Concrete patterns and idiomatic fixes for C23, Go 1.26, Rust 1.98, and Zig 0.16.0, with version-gated APIs flagged against the project baseline. - Use Case: When reviewing a Go request handler, identify an O(n²) slice scan inside a loop, replace it with a pre-built map, and defer unmeasured concerns like struct padding to profiling data. ## Quick Start Ask the AI to review this hot loop in my Rust parser for performance issues using the performance patterns skill.

Frequently Asked Questions about performance-patterns

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

FAQPage Schema
How do I optimize a hot loop in Go or Rust?▼

Start by confirming the loop is actually hot through its call context, then address factors in cost order: fix algorithmic complexity first, then allocations and redundant work. Verify claims with profiling tools like pprof or criterion before acting on memory or concurrency concerns.

What performance issues should a code review flag first?▼

Flag statically verifiable issues first: O(n²) patterns like linear search inside loops, allocations inside loops that could be hoisted, unbuffered I/O per item, and loop-invariant recomputation. Report cache and contention concerns as notes unless profiling data exists.

Which profiling tools work for C, Go, Rust, and Zig?▼

Use perf, valgrind cachegrind, or hyperfine for whole programs; Go pprof and benchstat; Rust criterion; and Zig poop or std.Io.Timestamp micro-benchmarks. For Go escape analysis, run go build -gcflags=-m to check claims statically.

Does the skill handle different language versions?▼

Yes, version-gated APIs are checked against the project baseline from the build manifest, such as the go.mod directive, Cargo.toml edition, or build.zig.zon minimum_zig_version. Entries requiring newer versions are presented as upgrade-gated options rather than applied silently.

When should I not apply micro-optimizations?▼

Avoid micro-optimizations in cold paths like initialization, error handling, and CLI parsing, where only egregious waste such as O(n²) growth warrants fixing. Never trade correctness, aliasing rules, or idiomatic allocations for speed.