Unit 02 of 02
Concurrency and Performance
Threads and locks, the memory model, cache-friendly data layout, profiling and benchmarking, managing compile times, package management and build tools — each paired with the question of where the cost moved.
Published Updated
Lessons
- 01 Threads and Locks std::thread and join, std::jthread, std::mutex with std::lock_guard, std::scoped_lock, std::unique_lock with std::condition_variable, a producer/consumer queue, and counting how many synchronization points a lock adds. 9 min read
- 02 The Memory Model std::atomic, read-modify-write operations, the seq_cst, acquire, release and relaxed memory orders, the happens-before relation, and counting how many synchronization points a release/acquire publish asks for. 10 min read
- 03 Cache-Friendly Data Layout The cache line, spatial and temporal locality, array of structures versus structure of arrays, row order and column order, false sharing, and counting how many non-contiguous jumps a data layout leaves. 9 min read
- 04 Profiling and Benchmarking Instrumentation versus sampling, finding the hot spot by placing counters, the warm-up, repetition and dead code rules of benchmarking, and how the place where a measurement starts changes the result. 10 min read
- 05 Managing Compile Times Forward declaration, trimming unnecessary includes, the pimpl idiom, opaque types, explicit instantiation and extern template, and how the cost gained at compile time moves to run time per object. 11 min read
- 06 Package Management and Build Tools Reproducible installation with a dependency table, version pinning and a lock file; how a header-only template library rebuilds every unit. 5 min read