cpu-architecture
/cpu-architecture
Understand caches, branches, and pipelines well enough to explain why equivalent code differs in speed by an order of magnitude. Use when optimising hot code or when performance does not match operation counts.
- Author
- Amey-Thakur ↗
- Repository
- AI-SKILLS ↗
- Licence
- MIT
- Last repository change
- 05.09.2026
Assessment and security
- Files in this package
- 1
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 05.09.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Understand caches, branches, and pipelines well enough to explain why equivalent code differs in speed by an order of magnitude. Use when optimising hot code or when performance does not match operation counts.
Original author description
Understand caches, branches, and pipelines well enough to explain why equivalent code differs in speed by an order of magnitude. Use when optimising hot code or when performance does not match operation counts.
How it works
- Method
- Boundaries
SKILL.md preview
--- name: cpu-architecture description: Understand caches, branches, and pipelines well enough to explain why equivalent code differs in speed by an order of magnitude. Use when optimising hot code or when performance does not match operation counts. --- # CPU architecture Modern processors are fast at predictable, local work and slow at unpredictable, scattered work. Two algorithms with identical operation counts can differ enormously because one respects the cache hierarchy and the other does not. ## Method 1. **Treat memory access as the dominant cost.** A cache miss costs hundreds of cycles while an arithmetic operation costs about one, so data layout matters more than instruction count. 2. **Favour sequential access.** Prefetching rewards linear traversal and cannot help pointer chasing, which is why arrays beat linked structures in practice (see data-structure-selection). 3. **Lay out data by access pattern.** Grouping fields used together improves cache line utilisation, and splitting hot from cold fields can transform a hot loop. 4. **Avoid unpredictable branches in hot loops.** Mispredictions cost tens of cycles, and branchless arithmetic or sorted input can remove them entirely. 5. **Watch for false sharing between threads.** Independent variables on one cache line cause cores to fight over it, producing contention with no logical sharing (see concurrency-primitives). 6. **Let the compiler vectorise.** Simple loops over contiguous data with no aliasing get vectorised automatically, and complex code prevents it. 7. **Profile at the hardware level when it matters.** Cache miss and branch miss counters explain what time-based profiling cannot (see profiling-cpu). ## Boundaries These effects matter in hot loops and are irrelevant in most application code, where clarity should win. Architectures differ substantially, so tuning for one may not transfer. Managed runtimes and interpreters add layers that dominate these effects (see performance-optimization).
Versions
| Repository | Score | Licence |
|---|---|---|
| This page · Amey-Thakur/AI-SKILLS | 90 | MIT |
| j4flmao/agent-skills | 100 | MIT |
Database snapshot: 13.11.2026 · package version 55ed20a0554c (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100hatch3r-perf-audit
Profiles and optimizes application performance against defined budgets. Use when investigating performance issues, auditing performance budgets, or optimizing hot paths. - 100rust-performance
Profile before optimizing, cut allocation out of hot paths, and treat LTO, codegen-units, PGO and target-cpu as the last five percent. Use when Rust code is too slow, when a benchmark regresses, when reviewing code that allocates or formats inside a loop, when release-profile or…