Skip to content

LessUp/cpp-high-performance-guide

C++ High Performance Guide

Stars CI License

English | 简体中文 | GitHub Pages | Discussions

Learn measurable C++20 performance engineering through runnable examples, benchmarks, and a VitePress-powered learning site.

Why this repository exists

This project is a practical guide to common C++ performance topics that are easy to talk about but harder to validate:

  • modern CMake and preset-driven builds
  • memory and cache layout decisions
  • modern C++ performance patterns
  • SIMD and vectorization
  • concurrency and lock-free basics
  • profiling and benchmark-driven reasoning

Every major topic is meant to be readable, buildable, and measurable.

What you can explore

Area What it covers
examples/01-cmake-modern/ modern CMake structure and anti-patterns
examples/02-memory-cache/ AOS vs SOA, false sharing, alignment, prefetch
examples/03-modern-cpp/ constexpr, move semantics, reserve, ranges
examples/04-simd-vectorization/ auto-vectorization, intrinsics, SIMD wrappers
examples/05-concurrency/ atomics, lock-free queue, OpenMP
docs/ bilingual learning path, profiling guide, troubleshooting, reference
openspec/ spec-driven development workflow and change history

Quick start

git clone https://github.com/LessUp/cpp-high-performance-guide.git
cd cpp-high-performance-guide

cmake --preset=release
cmake --build build/release

Run one benchmark:

./build/release/examples/02-memory-cache/aos_soa_bench

Validation commands

cmake --preset=debug && cmake --build build/debug && ctest --preset=debug
cmake --preset=release && cmake --build build/release && ctest --preset=release

cmake --preset=asan && cmake --build build/asan && ctest --preset=asan
cmake --preset=tsan && cmake --build build/tsan && ctest --preset=tsan
cmake --preset=ubsan && cmake --build build/ubsan && ctest --preset=ubsan

Documentation and learning path

Development workflow

This repository uses OpenSpec for non-trivial changes.

  1. Read the affected capability specs in openspec/specs/.
  2. Create or update a change under openspec/changes/<change-id>/.
  3. Implement tasks in dependency order.
  4. Run preset-driven validation.
  5. Use /review before merge for non-trivial work.
  6. Archive completed changes.

The repository also keeps AI tool guidance in:

  • AGENTS.md
  • CLAUDE.md
  • .github/copilot-instructions.md

Tech stack

  • Language: C++20
  • Build: CMake 3.22+, Ninja
  • Testing: Google Test, RapidCheck
  • Benchmarking: Google Benchmark
  • Docs: VitePress + GitHub Pages
  • Profiling: perf, FlameGraph, Valgrind, VTune

Contributing

See CONTRIBUTING.md for the contributor workflow, hooks setup, and OpenSpec process.