The Art of Writing Efficient Programs. An advanced programmer's guide to efficient hardware utilization and compiler optimizations using C++ examples
Book information
Description
Cover Title Page Copyright and Credits Contributors Table of Contents Preface Section 1 – Performance Fundamentals Chapter 1: Introduction to Performance and Concurrency Why focus on performance? Why performance matters What is performance? Performance as throughput Performance as power consumption Performance for real-time applications Performance as dependent on context Evaluating, estimating, and predicting performance Learning about high performance Summary Questions Chapter 2: Performance Measurements Technical requirements Performance measurements by example Performance benchmarking C++ chrono timers High-resolution timers Performance profiling The perf profiler Detailed profiling with perf The Google Performance profiler Profiling with call graphs Optimization and inlining Practical profiling Micro-benchmarking Basics of micro-benchmarking Micro-benchmarking and compiler optimizations Google Benchmark Micro-benchmarks are lies Summary Questions Chapter 3: CPU Architecture, Resources, and Performance Technical requirements The performance begins with the CPU Probing performance with micro-benchmarks Visualizing instruction-level parallelism Data dependencies and pipelining Pipelining and branches Branch prediction Profiling for branch mispredictions Speculative execution Optimization of complex conditions Branchless computing Loop unrolling Branchless selection Branchless computing examples Summary Questions Chapter 4: Memory Architecture and Performance Technical requirements The performance begins with the CPU but does not end there Measuring memory access speed Memory architecture Measuring memory and cache speeds The speed of memory: the numbers The speed of random memory access The speed of sequential memory access Memory performance optimizations in hardware Optimizing memory performance Memory-efficient data structures Profiling memory performance Optimizing algorithms for memory performance The ghost in the machine What is Spectre? Spectre by example Spectre, unleashed Summary Questions Chapter 5: Threads, Memory, and Concurrency Technical requirements Understanding threads and concurrency What is a thread? Symmetric multi-threading Threads and memory Memory-bound programs and concurrency Understanding the cost of memory synchronization Why data sharing is expensive Learning about concurrency and order The need for order Memory order and memory barriers Memory order in C++ Memory model Summary Questions Section 2 – Advanced Concurrency Chapter 6: Concurrency and Performance Technical requirements What is needed to use concurrency effectively? Locks, alternatives, and their performance Lock-based, lock-free, and wait-free programs Different locks for different problems Lock-based versus lock-free, what is the real difference? Building blocks for concurrent programming The basics of concurrent data structures Counters and accumulators Publishing protocol Smart pointers for concurrent programming Summary Questions Chapter 7: Data Structures for Concurrency Technical requirements What is a thread-safe data structure? The best kind of thread safety The real thread safety The thread-safe stack Interface design for thread safety Performance of mutex-guarded data structures Performance requirements for different uses Stack performance in detail Performance estimates for synchronization schemes Lock-free stack The thread-safe queue Lock-free queue Non-sequentially consistent data structures Memory management for concurrent data structures The thread-safe list Lock-free list Summary Questions Chapter 8: Concurrency in C++ Technical requirements Concurrency support in C++11 Concurrency support in C++17 Concurrency support in C++20 The foundations of coroutines Coroutine C++ syntax Coroutine examples Summary Questions Section 3 – Designing and Coding High-Performance Programs Chapter 9: High-Performance C++ Technical requirements What is the efficiency of a programming language? Unnecessary copying Copying and argument passing Copying as an implementation technique Copying to store data Copying of return values Using pointers to avoid copying How to avoid unnecessary copying Inefficient memory management Unnecessary memory allocations Memory management in concurrent programs Avoiding memory fragmentation Optimization of conditional execution Summary Questions Chapter 10: Compiler Optimizations in C++ Technical requirements Compilers optimizing code Basics of compiler optimizations Function inlining What does the compiler really know? Lifting knowledge from runtime to compile time Summary Questions Chapter 11: Undefined Behavior and Performance Technical requirements What is undefined behavior? Why have undefined behavior? Undefined behavior and C++ optimization Using undefined behavior for efficient design Summary Questions Chapter 12: Design for Performance Technical requirements Interaction between the design and performance Design for performance The minimum information principle The maximum information principle API design considerations API design for concurrency Copying and sending data Design for optimal data access Performance trade-offs Interface design Component design Errors and undefined behavior Making informed design decisions Summary Questions Assessments Chapter 1: Chapter 2: Chapter 3: Chapter 4: Chapter 5: Chapter 6: Chapter 7: Chapter 8: Chapter 9: Chapter 10: Chapter 11: Chapter 12: Other Books You May Enjoy Index
Similar books
Hands-On Design Patterns with C++
2023 · PDF
Hands-On Design Patterns with C++: Solve common C++ problems with modern design patterns and build robust applications
2023 · EPUB
The Art of Writing Efficient Programs: An advanced programmer's guide to efficient hardware utilization and compiler optimizations using C++ examples
2021 · PDF
The Art of Writing Efficient Programs: An advanced programmer's guide to efficient hardware utilization and compiler optimizations using C++ examples
2021 · PDF
The Art of Writing Efficient Programs: An advanced programmer's guide to efficient hardware utilization and compiler optimizations using C++ examples
2021 · EPUB
Hands-On Design Patterns with C++: Solve common C++ problems with modern design patterns and build robust applications
2019 · PDF
Hands-On Design Patterns with C++: Solve common C++ problems with modern design patterns and build robust applications
2019 · EPUB
Hands-On Design Patterns with C++: Solve common C++ problems with modern design patterns and build robust applications. Code
2019 · ZIP