Download the free Kindle app and start reading Kindle books instantly on your smartphone, tablet, or computer - no Kindle device required.
Read instantly on your browser with Kindle for Web.
Using your mobile phone camera - scan the code below and download the Kindle app.
Follow the author
OK
The Art of Writing Efficient Programs: An advanced programmer's guide to efficient hardware utilization and compiler optimizations using C++ examples
Purchase options and add-ons
Become a better programmer with performance improvement techniques such as concurrency, lock-free programming, atomic operations, parallelism, and memory management
Key Features
- Learn proven techniques from a heavyweight and recognized expert in C++ and high-performance computing
- Understand the limitations of modern CPUs and their performance impact
- Find out how you can avoid writing inefficient code and get the best optimizations from the compiler
- Learn the tradeoffs and costs of writing high-performance programs
Book Description
The great free lunch of "performance taking care of itself" is over. Until recently, programs got faster by themselves as CPUs were upgraded, but that doesn't happen anymore. The clock frequency of new processors has almost peaked, and while new architectures provide small improvements to existing programs, this only helps slightly. To write efficient software, you now have to know how to program by making good use of the available computing resources, and this book will teach you how to do that.
The Art of Efficient Programming covers all the major aspects of writing efficient programs, such as using CPU resources and memory efficiently, avoiding unnecessary computations, measuring performance, and how to put concurrency and multithreading to good use. You'll also learn about compiler optimizations and how to use the programming language (C++) more efficiently. Finally, you'll understand how design decisions impact performance.
By the end of this book, you'll not only have enough knowledge of processors and compilers to write efficient programs, but you'll also be able to understand which techniques to use and what to measure while improving performance. At its core, this book is about learning how to learn.
What you will learn
- Discover how to use the hardware computing resources in your programs effectively
- Understand the relationship between memory order and memory barriers
- Familiarize yourself with the performance implications of different data structures and organizations
- Assess the performance impact of concurrent memory accessed and how to minimize it
- Discover when to use and when not to use lock-free programming techniques
- Explore different ways to improve the effectiveness of compiler optimizations
- Design APIs for concurrent data structures and high-performance data structures to avoid inefficiencies
Who this book is for
This book is for experienced developers and programmers who work on performance-critical projects and want to learn new techniques to improve the performance of their code. Programmers in algorithmic trading, gaming, bioinformatics, computational genomics, or computational fluid dynamics communities will get the most out of the examples in this book, but the techniques are fairly universal. Although this book uses the C++ language, the concepts demonstrated in the book can be easily transferred or applied to other compiled languages such as C, Java, Rust, Go, and more.
Table of Contents
- Introduction to Performance and Concurrency
- Performance Measurements
- CPU Architecture, Resources, and Performance Implications
- Memory Architecture and Performance
- Threads, Memory, and Concurrency
- Concurrency and Performance
- Data Structures for Concurrency
- Concurrency in C++
- High-Performance C++
- Compiler Optimizations in C++
- Undefined Behavior and Performance
- Design for Performance
- ISBN-101800208111
- ISBN-13978-1800208117
- PublisherPackt Publishing
- Publication dateOctober 22, 2021
- LanguageEnglish
- Dimensions7.5 x 1.05 x 9.25 inches
- Print length464 pages
Frequently bought together

Customers who viewed this item also viewed
- Systems Performance (Addison-Wesley Professional Computing Series)PaperbackFREE Shipping by AmazonGet it as soon as Sunday, Sep 20
- Effective Modern C++: 42 Specific Ways to Improve Your Use of C++11 and C++14PaperbackGet it as soon as Tuesday, Sep 29
- C++ Concurrency in ActionPaperbackFREE Shipping by AmazonGet it as soon as Sunday, Sep 20Only 6 left in stock (more on the way).
- Tour of C++, A (C++ In-Depth Series)PaperbackFREE Shipping by AmazonGet it as soon as Sunday, Sep 20
- C++ Software Design: Design Principles and Patterns for High-Quality SoftwarePaperbackFREE Shipping by AmazonGet it as soon as Monday, Sep 21
- Inside the Machine: An Illustrated Introduction to Microprocessors and Computer ArchitecturePaperbackFREE Shipping by AmazonGet it as soon as Monday, Sep 21
Customers also bought or read
- C++ Memory Management: Write leaner and safer C++ code using proven memory-management techniques
Paperback$29.99$29.99Delivery Mon, Sep 21 - C++ High Performance: Master the art of optimizing the functioning of your C++ code, 2nd Edition
Paperback$59.99$59.99FREE delivery Mon, Sep 21 - Effective Modern C++: 42 Specific Ways to Improve Your Use of C++11 and C++14
Paperback$44.24$44.24FREE delivery Sep 29 - Oct 14 - C++ Software Design: Design Principles and Patterns for High-Quality Software
Paperback$51.24$51.24FREE delivery Mon, Sep 21 - Modern C++ Programming Cookbook: Master Modern C++ with comprehensive solutions for C++23 and all previous standards
Paperback$26.53$26.53Delivery Mon, Sep 21 - Operating Systems: Three Easy Pieces#1 Best SellerComputer Operating Systems Theory
Paperback$28.27$28.27Delivery Mon, Sep 21 - Hands-On Design Patterns with C++: Solve common C++ problems with modern design patterns and build robust applications
Paperback$48.99$48.99FREE delivery Sun, Sep 20 - Performance Analysis and Tuning on Modern CPUs: Learn to write fast software like a pro
Paperback$31.65$31.65Delivery Mon, Sep 21 - TCP/IP Illustrated: The Protocols, Volume 1 (Addison-Wesley Professional Computing Series)#1 Best SellerTCP-IP
Hardcover$64.49$64.49FREE delivery Mon, Sep 21 - Modern CMake for C++: Effortlessly build cutting-edge C++ code and deliver high-quality solutions
Paperback$26.81$26.81Delivery Mon, Sep 21 - Beautiful C++: 30 Core Guidelines for Writing Clean, Safe, and Fast Code
Paperback$48.09$48.09FREE delivery Sep 22 - 25 - Design Patterns: Elements of Reusable Object-Oriented Software
Hardcover$24.35$24.35Delivery Mon, Sep 21 - Bare-Metal Embedded C Programming: Develop high-performance embedded systems with C for Arm microcontrollers
Paperback$31.91$31.91Delivery Mon, Sep 21 - Inside the Machine: An Illustrated Introduction to Microprocessors and Computer Architecture
Paperback$46.15$46.15FREE delivery Mon, Sep 21 - Asynchronous Programming with C++: Build blazing-fast software with multithreading and asynchronous programming for ultimate efficiency
Paperback$41.99$41.99FREE delivery Mon, Sep 21 - C++ Best Practices: 45ish Simple Rules with Specific Action Items for Better C++ (With Color Syntax Highlighting)
Paperback$25.99$25.99Delivery Mon, Sep 21 - Building Low Latency Applications with C++: Develop a complete low latency trading ecosystem from scratch using modern C++
Paperback$39.99$39.99FREE delivery Mon, Sep 21 - C Programming Language, 2nd Edition#1 Best SellerC Programming Language
Paperback$60.30$60.30FREE delivery Sun, Sep 20 - Modern X86 Assembly Language Programming: Covers X86 64-bit, AVX, AVX2, and AVX-512
Paperback$49.90$49.90FREE delivery Mon, Sep 21 - Rust for Rustaceans: Idiomatic Programming for Experienced Developers
Paperback$29.49$29.49Delivery Sun, Sep 20 - Programming with C++20: Concepts, Coroutines, Ranges, and more
Paperback$38.00$38.00FREE delivery Mon, Sep 21 - LLVM Code Generation: A deep dive into compiler backend development
Paperback$34.99$34.99Delivery Mon, Sep 21
From the brand
-
See more at our store:
-
Packt is a leading publisher of technical learning content with the ability to publish books on emerging tech faster than any other.
Our mission is to increase the shared value of deep tech knowledge by helping tech pros put software to work.
We help the most interesting minds and ground-breaking creators on the planet distill and share the working knowledge of their peers.
From the Publisher
How has your background helped you to write this book?
I started programming as a college student when even the simplest programs had to be written with performance in mind. While times have changed, I kept finding myself working in the areas where the hardware capabilities were never enough: first, in computational physics and then in electronic design automation. By choice or circumstance, I have always been programming close to hardware - the skill that is in demand once more in recent years in areas like low latency and high-performance concurrency. As for compilers, their ability to improve performance is miles ahead of what it once was, and so is the potential magnitude of the failure when the expected performance boost does not materialize due to a quirk of the language or a peculiarity of the hardware interfering with the programmer's intent. All in all, I found the old habits, if not the old knowledge, relevant again in the modern age of high-performance computing.
What part or parts of the book are your favorite, and why?
Several parts, and the experience of writing them, stand out in my memory. First of all, it's the chapter on designing for performance. So often, performance is considered a feature to be added later. The mantra "do not optimize prematurely" is as widely known as it is misunderstood; its intended meaning is much more nuanced than most programmers realize. The idea that performance targets are as much a part of the original design specification as the feature list often comes as a surprise; if I can teach one thing to the readers of my book, I would want it to be this idea.
Other favorite moments are the ones where I found and presented some minor or innocuous change that has an unexpectedly large effect on performance. Certain compiler optimizations, seemingly trivial changes to memory access, and clever concurrent algorithms all have that element of surprise and even disbelief: "It does WHAT?"
In what ways have you been active in the community?
Mostly in various educational activities, like conference presentations and CppCon Academy classes. Sharing my knowledge and having the knowledge and experience of others shared with me are where I find my role in the C++ community most useful.
What makes this book better than other similar titles?
Obviously, the content, the presentation, and the style! Seriously though, there are several strengths of the book in my mind. First is the emphasis on not just imparting knowledge and information, but explaining how we came to know what we know, and how such knowledge can be re-discovered when the next generations of hardware, languages, and compilers will make the guidelines of today obsolete. In this way, it is a book about learning to learn. Second is the scope, the breadth of it: it is rare to find, in one place, the presentation of the performance effects that originate from the hardware, the compilers, the language features, and the design decisions, and their mutual interactions.
Editorial Reviews
About the Author
Fedor G. Pikus is a chief engineering scientist in the Mentor IC Segment of Siemens Digital Industries Software and is responsible for the long-term technical direction of Calibre products, the design and architecture of software, and research into new software technologies. His previous roles included senior software engineer at Google and chief software architect at Mentor Graphics. Fedor is a recognized expert in high-performance computing and C++. He has presented his works at CPPCon, SD West, DesignCon, and in software development journals, and is also an O'Reilly author. Fedor has over 25 patents and over 100 papers and conference presentations on physics, EDA, software design, and C++.
Product details
- Publisher : Packt Publishing
- Publication date : October 22, 2021
- Language : English
- Print length : 464 pages
- ISBN-10 : 1800208111
- ISBN-13 : 978-1800208117
- Item Weight : 7.4 ounces
- Dimensions : 7.5 x 1.05 x 9.25 inches
- Best Sellers Rank: #203,482 in Books (See Top 100 in Books)
- Customer Reviews:
About the author

Fedor G Pikus is a Technical Fellow at Siemens Digital Industries Software and the director of the Advanced Projects Team. His earlier positions included a Senior Software Engineer at Google and a Chief Software Architect for Calibre PERC, LVS, and DFM at Mentor Graphics. He joined Mentor Graphics in 1998 when he made a switch from academic research in computational physics to the software industry. Fedor is a recognized expert on high-performance computing and C++, he presented his works at C++Now, CPPCon, SD West, DesignCon, in Software Development Journal, and is also an O'Reilly author. His responsibilities as a Chief Scientist include planning the long-term technical direction of Calibre products, directing and training the engineers who work on these products, design, and architecture of the software, and research in new design and software technologies. Fedor has over 25 patents and over 100 papers and conference presentations on physics, EDA, software design, and C++ language.



















