Optimized C++
387 pages
English
PDF
4.5

Optimized C++

Optimized C++

Author:

Year:

Summary:

Introduction

The book "Optimized C++" by Kurt Guntheroth is not just another textbook on the C++ language, but a deep practical guide to writing high-performance code. Published in 2016, it remains relevant today because it addresses the fundamental principles of optimization that are independent of the standard version. The book is aimed at experienced developers who already write confidently in C++ but want to take their programs to a new level of speed and efficiency.

What This Book Is About

The book is dedicated to a systematic approach to optimizing C++ code. The author does not provide ready-made "magic" recipes but teaches you to think in terms of performance: how to measure a bottleneck, which tools to use (profilers, benchmarks), how modern hardware works (cache memory, processor pipelines), and how the compiler transforms your code. Main topics:

  • Profiling and identifying bottlenecks.
  • Optimizing memory usage: cache, alignment, data locality.
  • Efficient use of STL containers.
  • Optimizing strings and algorithms.
  • Working with compiler optimizations (flags, inlining, vectorization).
  • Multithreading and atomic operations.
  • Measuring and comparing performance.

Who This Book Is For

The book is intended for intermediate to advanced C++ programmers who are already familiar with syntax, OOP, and the standard library. It will be useful for:

  • Game developers, where every frame counts.
  • Specialists in high-load systems (finance, telecom, real-time).
  • Engineers working on embedded systems with limited resources.
  • Anyone who wants to understand how hardware works and how to write processor-friendly code.

What the Reader Will Learn

After reading the book, you will be able to:

  • Properly set up the profiling environment (gprof, perf, Intel VTune).
  • Understand how cache memory affects speed and how to organize data for maximum locality.
  • Choose optimal containers and algorithms for a specific task.
  • Use move semantics and smart pointers without losing performance.
  • Apply intrinsics and SIMD instructions for loop vectorization.
  • Avoid common pitfalls that slow down code (virtual functions in hot paths, excessive copying).
  • Conduct A/B testing of optimizations and make data-driven decisions.

Strengths of the Book

Practical focus. Each chapter contains code examples that can be immediately run and measured. The author does not limit himself to theory — he shows real benchmarks and compares results before and after optimization.

Systematic approach. Guntheroth teaches not just to "speed up," but first to measure, then analyze, and only then modify the code. This saves you from premature optimization, which often harms readability.

Deep understanding of hardware. The book explains how caches, branch predictors, and instruction pipelines work. This gives the reader a foundation for independently finding bottlenecks.

Focus on modern C++. Although the book was published in 2016, it covers C++11/14, which is still the baseline for many projects. Move semantics, lambdas, smart pointers — all are considered in the context of performance.

Clear structure. The book is divided into three parts: "Measurement," "Hardware," and "Code Optimization." This allows it to be read either sequentially or selectively.

Who It Is Recommended For

I recommend this book to everyone who writes in C++ and wants their code to run as fast as possible. It will be especially useful for those who have already encountered performance issues and are looking for ways to solve them.

Recommendations