The Art of Writing Efficient Programs
446 pages
English
PDF
4.5

The Art of Writing Efficient Programs

The Art of Writing Efficient Programs

Author:

Year:

Summary:

Introduction

The book "The Art of Writing Efficient Programs" by Fedor Pikus is not just another C++ textbook. It is a deep dive into the world of performance, optimization, and architectural decisions that transform ordinary code into a highly efficient tool. Published in 2021 by Packt, this 446-page book has become a go-to guide for many developers seeking to get the most out of modern hardware.

Fedor Pikus is a recognized expert in high-performance computing, having worked at Google and other technology giants. His experience and practical approach to solving performance problems make this book unique. Unlike many abstract theoretical works, Pikus offers concrete, proven methodologies supported by C++ examples.

What is this book about?

The book is dedicated to the art of creating programs that run as fast and efficiently as possible, utilizing CPU, memory, and I/O subsystem resources with maximum efficiency. The author systematically breaks down key performance aspects, starting from the basics and progressing to advanced techniques.

Main topics covered in the book:

  • Performance measurement: how to properly profile code, interpret results, and find bottlenecks.
  • Memory optimization: cache memory, data alignment, locality of reference, working with dynamic memory.
  • Concurrency and multithreading: efficient use of threads, synchronization, avoiding data races and deadlocks.
  • Algorithm optimization: choosing the right data structures, algorithmic complexity and its impact on real-world performance.
  • Vectorization and SIMD: using CPU instructions for parallel data processing.
  • Working with the compiler: how to help the compiler generate faster code, optimization flags, inlining.
  • Designing for performance: architectural patterns that inherently build in high speed.

Who is this book for?

The book is aimed at developers who already have experience programming in C++ (or another systems language) and want to reach the next level — creating truly fast and efficient applications. It will be useful for:

  • Game and graphics engine developers.
  • Engineers working on high-load servers and databases.
  • Embedded systems and IoT specialists.
  • Anyone writing code for financial, scientific, or engineering calculations.
  • Senior university students in technical fields studying systems programming.

What will the reader learn?

After reading the book, the reader will be able to:

  • Properly evaluate the performance of their code using profilers (perf, Valgrind, Google Benchmark).
  • Understand how CPU cache memory works and write code that maximizes its usage.
  • Efficiently manage memory, avoiding fragmentation and unnecessary allocations.
  • Write safe and fast multithreaded code using modern synchronization primitives.
  • Apply SIMD instructions to speed up computations by 2-4 times without losing code readability.
  • Choose optimal data structures (std::vector vs std::list, hash tables, trees) for a specific task.
  • Use C++17/20 features (e.g., std::optional, std::variant, constexpr) to improve performance.
  • Design an application architecture that is inherently oriented toward high speed.

Strengths of the book

Fedor Pikus's book stands out from other optimization publications due to several key features:<

Recommendations