
Cpu Cache Opt
Teaches Claude to diagnose and fix cache performance issues in C/C++ and Rust using perf counters, data layout transformations, and false sharing detection. You'd reach for this when your program shows high cache miss rates or when multithreaded code inexplicably runs slower than single-threaded. It walks through AoS to SoA conversions, cache line alignment, prefetching strategies, and loop blocking for matrix operations. The perf stat examples are immediately useful, showing exactly which counters matter and what thresholds indicate trouble. Honest take: cache optimization is one of those areas where measurement comes first, and this skill front-loads the profiling commands before suggesting fixes, which is the right order.
- skills.sh installs
- 709
- GitHub stars
- 279
- last updated
- Aug 21, 2026
Install
$ npx -y skills add mohitmishra786/low-level-dev-skills --skill cpu-cache-opt --agent claude-codeInstalls into .claude/skills of the current project.
Files
CPU Cache Optimization
Purpose
Guide agents through cache-aware programming: diagnosing cache misses with perf, data layout transformations (AoS→SoA), false sharing detection and fixes, prefetching, and cache-friendly algorithm design.
Triggers
- "My program has high cache miss rates — how do I fix it?"
- "What is false sharing and how do I detect it?"
- "Should I use AoS or SoA data layout?"
- "How do I measure cache performance with perf?"
- "How do I use __builtin_prefetch?"
- "My multithreaded program is slower than single-threaded due to cache"
Workflow
1. Measure cache performance
# Basic cache counters
perf stat -e cache-references,cache-misses,cycles,instructions ./prog
# L1/L2/L3 miss breakdown
perf stat -e \
L1-dcache-load-misses,\
L1-dcache-loads,\
L2-dcache-load-misses,\
LLC-load-misses,\
LLC-loads \
./prog
# Cache miss rate = L1-dcache-load-misses / L1-dcache-loads
# > 5% is concerning; > 20% is severe
# False sharing detection
perf stat -e \
machine_clears.memory_ordering,\
mem_load_l3_hit_retired.xsnp_hitm \
./prog
2. Cache line basics
Sponsors
Details
- Repository
- github.com/mohitmishra786/low-level-dev-skills
- Categories
- Frontend Development, Debugging, Rust
- First seen
- Jun 3, 2026
More from mohitmishra786/low-level-dev-skills
All 54- Assembly Arm707
- Lldb703
- Elf Inspection702
- Simd Intrinsics701
- Make697
- Memory Model693
- Freertos691
- Linux Kernel Modules689
- Ninja681
- Heaptrack676
- Rust Profiling673
- Ebpf672
- Msvc Cl671
- Fuzzing670
- Binutils665
- Linkers Lto663
- Conan Vcpkg659
- Dynamic Linking650
- Rust Security624
- Rust Ffi613
- Rust Unsafe611
- Pgo610
- Interpreters609
- Cargo Workflows608