A progressive series of one-day C++ projects designed to build the foundational skills needed for high-performance systems development. Each project introduces essential concepts while building toward the competence required for high-performance engineering. Some of these projects may take longer than a day, and that's fine!
Complete Solutions: This is the main branch containing project implementations.
For learners: Clone the template branch to get started:
git clone -b template https://github.com/t-flora/cpp-perf-foundations.gitFor instructors/reference: You're in the right place! This branch contains implementations.
This repository uses a two-branch approach:
templatebranch: Empty project templates with starter code and TODO comments for learnersmainbranch: Complete implementations and solutions for reference
Workflow for learners:
# Clone template branch to start learning
git clone -b template https://github.com/t-flora/cpp-perf-foundations.git
cd cpp-perf-foundations
# Work on your solutions...
# Optional: Compare with complete solutions
git remote add upstream https://github.com/t-flora/cpp-perf-foundations.git
git fetch upstream main
git checkout -b solutions upstream/maincpp-foundations/
├── README.md # This file
├── CMakeLists.txt # Root CMake file
├── .github/
│ └── workflows/
│ └── ci.yml # GitHub Actions CI
├── day1-cmake-ci/
│ ├── README.md
│ ├── CMakeLists.txt
│ ├── src/
│ │ ├── calculator.h
│ │ ├── calculator.cpp
│ │ └── main.cpp
│ └── tests/
│ └── test_calculator.cpp
├── day2-header-library/
│ ├── README.md
│ ├── CMakeLists.txt
│ ├── include/
│ │ └── vector_math/
│ │ └── vector_math.h
│ ├── examples/
│ │ └── example_usage.cpp
│ └── tests/
│ └── test_vector_math.cpp
├── day3-docker-benchmarks/
│ ├── README.md
│ ├── CMakeLists.txt
│ ├── Dockerfile
│ ├── run_benchmarks.sh
│ ├── src/
│ │ └── sorting_benchmarks.cpp
│ └── results/
│ └── .gitkeep
├── day4-container-performance/
│ ├── README.md
│ ├── CMakeLists.txt
│ ├── src/
│ │ └── container_comparison.cpp
│ ├── scripts/
│ │ └── plot_results.py
│ └── results/
│ └── .gitkeep
├── day5-realtime-processor/
│ ├── README.md
│ ├── CMakeLists.txt
│ ├── src/
│ │ └── market_data_processor.cpp
│ ├── data/
│ │ └── sample_trades.csv
│ └── tests/
│ └── test_vwap.cpp
└── day6-concurrent-calculator/
├── README.md
├── CMakeLists.txt
├── src/
│ ├── thread_pool.h
│ ├── concurrent_calculator.cpp
│ └── benchmark_concurrency.cpp
├── tests/
│ └── test_thread_safety.cpp
└── scripts/
└── plot_scaling.py
Goal: Master the build system that every C++ project uses
What You'll Build: Simple calculator library with multiple source files
calculator.h/cppwith add/subtract/multiply/divide functionsmain.cppthat demonstrates library usage- CMake configuration for library and executable
- GitHub Actions CI pipeline for Linux/macOS
- clang-format integration for code style
Skills Gained:
- CMake basics (targets, linking, dependencies)
- CI/CD setup with GitHub Actions
- Professional C++ project structure
- Code formatting and style consistency
Essential Reading (2-3 hours before coding):
- CMake Tutorial - Official tutorial, focus on steps 1-4
- Modern CMake Practices - Modern target-based approach
- GitHub Actions CMake Workflow - Working starter template
- CMake Template Project - Complete example with CI
Why it matters: Every real C++ project needs this foundation. Without solid build systems, you can't collaborate or deploy code professionally in any high-performance domain.
Goal: Understand how modern C++ libraries are distributed
What You'll Build: Vector/matrix operations library for 2D/3D vectors
- Single header file with templated vector operations
- Example usage demonstrating the API
- CMake export files for easy integration
If time permits:
- Documentation with usage examples
- A few unit tests with Google Test
Skills Gained:
- Template programming fundamentals
- Header-only library design patterns
- Package management and distribution
- API design principles
Essential Reading (2-3 hours before coding):
- Effective Modern C++ - Item 30 - Perfect forwarding for template performance
- Expression Templates Explained (ModernesCpp) - Eliminating temporary objects in mathematical operations
- C++ Reference: constexpr specifier - Compile-time computation fundamentals
- Google Highway SIMD Library - Cross-platform vectorization basics
Additional resources:
- Modern C++ Header-Only Libraries - Examples and best practices
- Google Test Primer - Testing fundamentals
- API Design Principles - Creating clean interfaces
Tools to for quick performance scans:
- Compiler Explorer - See assembly output from your optimizations
- Quick Bench - Online benchmarking for code snippets
- C++ Insights - Understand template instantiation
Why it matters: Most high-performance C++ libraries are header-only for optimal compilation and inlining. Understanding this pattern is essential for systems programming.
Goal: Learn Docker + performance measurement
What You'll Build: Benchmark suite comparing sorting algorithms
- Performance comparison of std::sort vs quicksort vs radix sort
- Google Benchmark integration with proper statistical analysis
- Multi-stage Dockerfile (separate build and runtime stages)
- Automated script to run containers and export results
- Performance graphs and analysis
Skills Gained:
- Docker containerization for C++ projects
- Scientific performance measurement
- Benchmark design and interpretation
- CI integration with performance testing
Essential Reading (2-3 hours before coding):
- Google Benchmark User Guide - Focus on basic usage and avoiding optimization
- Docker Best Practices for C++ - Multi-stage builds and optimization
- Performance Analysis Basics - Understanding bottlenecks
Why it matters: All modern high-performance systems run in containers, and performance measurement is critical for optimization decisions.
Goal: Understand when to use different containers
What You'll Build: Systematic performance comparison of STL containers
- Compare std::vector, std::unordered_map, std::map, std::set for different operations
- Vary data sizes (100, 10K, 1M elements) and access patterns
- Generate CSV results with timing data
- Python script to create performance visualizations
- Decision guide for container selection
Skills Gained:
- Deep understanding of STL container performance characteristics
- Systematic benchmarking methodology
- Data analysis and visualization
- Performance-driven decision making
Essential Reading (2-3 hours before coding):
- STL Container Performance - Time complexity tables for all containers
- Cache-Friendly Data Structures - Memory layout impact on performance
- When to Use Which Container - Practical decision guide
Why it matters: High-performance systems live or die on container choice. A wrong data structure can cost microseconds per operation, which translates to real performance bottlenecks.
Goal: Handle streaming data efficiently
What You'll Build: Mock data processor with real-time analytics
- Parse CSV stream of data records (timestamp, identifier, value, quantity)
- Calculate moving averages and other windowed statistics per identifier
- Implement sliding window calculations using ring buffers
- Output real-time results with configurable update frequency
- Handle data validation and error cases
Skills Gained:
- Stream processing patterns
- Circular buffers and windowed calculations
- Real-time analytics concepts
- Real-time system design principles
Essential Reading (2-3 hours before coding):
- Circular Buffer Implementation - Lock-free ring buffer concepts
- VWAP Calculation - Understanding volume-weighted average price
- Stream Processing Patterns - Real-time data processing fundamentals
- CSV Parsing in C++ - Efficient file processing techniques
Goal: Learn thread safety and parallel processing fundamentals
What You'll Build: Multi-threaded mathematical computation system
- Thread pool for distributing CPU-intensive calculations
- Thread-safe queue using std::mutex and std::condition_variable
- Parallel processing of mathematical operations (matrix multiplication, prime finding)
- Benchmark comparing single-threaded vs multi-threaded performance
- Proper synchronization and resource management
Skills Gained:
- std::thread, std::mutex, std::condition_variable
- Thread pool design patterns
- Race condition prevention
- Lock-free data structures (std::atomic basics)
- Scalability measurement and analysis
Essential Reading (2-3 hours before coding):
- (Paid textbook) C++ Concurrency in Action - Chapter 2 - Managing threads
- Thread Pool Tutorial - Basic threading primitives
- Condition Variables in C++ - Synchronization fundamentals
- std::atomic Basics - Lock-free programming introduction
- Core Guidelines - CP - Best practices from Core Guidelines
Why it matters: High-performance systems are inherently concurrent - data processing, task scheduling, and resource management all happen in parallel. Understanding thread safety is essential for scalable systems.
- C++17 or later compiler (GCC 9+, Clang 10+, or MSVC 2019+)
- CMake 3.16+
- Git
- Docker (for Day 3)
- Python 3.8+ with matplotlib (for Day 4 visualization)
git clone <your-repo-url>
cd cpp-foundations
mkdir build && cd build
cmake ..
make -j$(nproc)
ctest # Run all testscd day1-cmake-ci
mkdir build && cd build
cmake ..
make
./calculator_demoEach day builds on the previous:
- Build Systems → You can compile and distribute C++ code professionally
- Header Libraries → You understand modern C++ distribution patterns
- Containers + Benchmarks → You can measure and optimize performance
- Data Structures → You make informed choices about algorithms and containers
- Stream Processing → You can handle real-time data efficiently
- Concurrency → You understand thread safety and parallel processing fundamentals
After completing all 6 projects, you should be able to:
- Set up a new C++ project with CMake and CI from scratch
- Design and implement header-only libraries
- Write and interpret performance benchmarks
- Choose appropriate data structures for different use cases
- Process streaming data efficiently
- Write thread-safe concurrent code
- Containerize C++ applications for deployment
With these foundational skills mastered, you'll be ready to tackle more ambitious projects like:
- High-performance order book implementation
- Low-latency data processing systems
- Distributed system components
- Real-time analytics engines
Each day should follow this pattern:
- Morning (2-3 hours): Read assigned materials for the day
- Afternoon (4-5 hours): Implement the project
- Evening (1 hour): Document learnings and prepare for next day
Time Management: Don't spend more than 3 hours on reading per day. The goal is practical competence, not theoretical mastery.
This project follows semantic versioning adapted for educational content:
- Major: Breaking changes to project structure or prerequisites
- Minor: New projects or significant enhancements
- Patch: Bug fixes and documentation updates
This is a learning repository. Each project should be:
- Completable in one focused day (6-8 hours)
- Well-documented with clear learning objectives
- Professionally structured with proper testing
- Incrementally building toward real-world skills
Remember: The goal isn't to build the most sophisticated systems possible, but to develop the foundational competence that makes sophisticated systems achievable in the first place.