Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Perf-Tune Skill

Professional CPU performance optimization skill covering 10 performance dimensions, Top-Down Microarchitecture Analysis (TMA) workflow, and multi-agent optimization.

Overview

Perf-Tune is a professional performance optimization skill for AI coding agents. It provides systematic CPU performance analysis and source-level optimization.

Key Features

  • 5 Languages: C, C++, Rust, Go, Python (native extensions)
  • 10 Performance Dimensions: P1-P10 coverage matrix (Memory Access through I/O)
  • TMA Workflow: Top-Down Microarchitecture Analysis from L1-L3
  • Multi-Agent: Parallel optimization agents for memory, computation, branch prediction, code layout, multithreading
  • 100+ Optimization Techniques: Cache-friendly data structures, vectorization, loop transforms, branchless code, PGO/BOLT, false sharing elimination, huge pages, system tuning
  • Tool Integration: Linux perf, Intel VTune, AMD uProf, Apple Instruments, cargo bench, go test -bench

Installation

cp -r perf-tune ~/.claude/skills/
cp -r perf-tune ~/.codex/skills/
cp -r perf-tune ~/.config/opencode/skills/

Usage

Trigger Phrases

"Optimize this code", "Profile this program", "Find the bottleneck", "/perf", "/tune", "/optimize"

Scan Modes

Mode Use Case Scope
Quick Hotspot identification PMU counters, top bottlenecks, quick wins
Standard Module-level optimization Full TMA, multi-dimension, 1-2 rounds
Deep Whole-program optimization All 10 dims, iterative, multi-agent, 2-3 rounds

Example

User: /tune deep ./my_project → [MODE] deep → [RECON] C++/CMake, x86-64 → [MEASURE] Backend:Memory 45%, IPC 0.7 → [PLAN] 3 Agents... → [REPORT] IPC +35%, cache-miss -60%

Architecture

TMA-Driven Optimization Model

Track Dimensions Method What It Optimizes
Memory-driven P1, P7 Measure miss rates → locate access → apply cache/prefetch/layout Present memory bottlenecks
Compute-driven P2, P6 Measure IPC/ports → check vectorize/loop/inline → apply Present computation inefficiencies
Layout-driven P4, P9 Measure Frontend Bound → check layout/PGO/ITLB → apply Code layout issues
Concurrency-driven P5 Measure scaling → check false sharing/locks/scheduling → apply Multithreading issues
Config-driven P8, P10 Check system config → compare baseline → adjust Misconfigurations

10 Performance Dimensions

# Dimension Coverage
P1 Memory Access Cache-friendly data structures, DTLB, prefetching
P2 Computation Vectorization, loop optimization, inlining
P3 Branch Prediction Branchless, lookup tables, predication
P4 Front-End Code layout, BB placement, PGO/BOLT, ITLB
P5 Multithreading Scaling, false sharing, task scheduling
P6 Data Dependencies Critical path analysis, chain breaking, ILP
P7 Memory Bandwidth Compression, quantization, streaming stores
P8 System Tuning NUMA, huge pages, kernel params, C-states
P9 Compiler Flags, pragmas, function attributes, LTO
P10 I/O & External System calls, external latency, async I/O

Multi-Agent Workflow

Phase 1: Recon + Measurement
Phase 2: TMA Diagnosis → Agent allocation
Phase 3: Parallel Agents (R1)
Phase 4: Coverage Evaluation → R2 if gaps
Phase 5: Report with before/after metrics

File Structure

perf-tune/
├── SKILL.md
├── agent.md
├── README.md / README_CN.md
└── references/
    ├── core/         (6)  # Measurement, microarchitecture, terminology, analysis, TMA, CPU features
    ├── optimization/ (15) # Memory(4) + Computation(4) + Branch(1) + CodeLayout(3) + Other(2) + Multithreading(1)
    ├── checklists/   (5)  # Coverage matrix + C++, Rust, Go, Python
    ├── languages/    (3)  # C++, Rust, Go deep-dive patterns
    └── tools/        (3)  # perf, VTune, benchmarking

Supported Technologies

Languages: C, C++, Rust, Go, Python | Architectures: x86-64, ARM64, RISC-V | Tools: Linux perf, Intel VTune, AMD uProf, Apple Instruments, cargo bench, go test -bench

Disclaimer

This skill provides optimization recommendations. Always verify correctness by running tests after any code change. Some optimizations may be architecture-specific and not portable.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors