| Digital List Price: | $35.99 |
| Kindle Price: | $26.99 Save $9.00 (25%) |
| Sold by: | Amazon.com Services LLC |
Your Memberships & Subscriptions
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.
The Art of Writing Efficient Programs: An advanced programmer's guide to efficient hardware utilization and compiler optimizations using C++ examples 1st Edition, Kindle Edition
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-13978-1800208117
- Edition1st
- PublisherPackt Publishing
- Publication dateOctober 22, 2021
- LanguageEnglish
- File size16045 KB
Kindle E-Readers
- Kindle Paperwhite
- Kindle Paperwhite (5th Generation)
- Kindle Touch
- Kindle Voyage
- Kindle
- Kindle Oasis
- All new Kindle paperwhite
- All New Kindle E-reader
- Kindle Oasis (9th Generation)
- Kindle Paperwhite (10th Generation)
- Kindle Paperwhite (11th Generation)
- All New Kindle E-reader (11th Generation)
- Kindle Scribe (1st Generation)
- Kindle (10th Generation)
- Kindle Oasis (10th Generation)
Fire Tablets
Free Kindle Reading Apps
Customers who read this book also read
From the brand
-
-
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
- ASIN : B09BZTGJM2
- Publisher : Packt Publishing; 1st edition (October 22, 2021)
- Publication date : October 22, 2021
- Language : English
- File size : 16045 KB
- Text-to-Speech : Enabled
- Screen Reader : Supported
- Enhanced typesetting : Enabled
- X-Ray : Not Enabled
- Word Wise : Not Enabled
- Print length : 464 pages
- Page numbers source ISBN : 1800208111
- Best Sellers Rank: #831,943 in Kindle Store (See Top 100 in Kindle Store)
- #99 in C++ Programming
- #142 in Computer Systems Analysis & Design (Kindle Store)
- #280 in C++ Programming Language
- 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.
Customer reviews
Customer Reviews, including Product Star Ratings help customers to learn more about the product and decide whether it is the right product for them.
To calculate the overall star rating and percentage breakdown by star, we don’t use a simple average. Instead, our system considers things like how recent a review is and if the reviewer bought the item on Amazon. It also analyzed reviews to verify trustworthiness.
Learn more how customers reviews work on AmazonCustomers say
Customers find the book's content useful, interesting, and open their eyes on some subjects. They describe it as a joy to read and connects what they learned in school to real life.
AI-generated from the text of customer reviews
Customers find the book's content useful, interesting, and open their eyes to some subjects for experienced developers. They say it teaches beginners and connects what they learned in school to real-life situations. Readers also mention the book is amazing regarding low-level programming and extracting power from hardware.
"Fabulous book, it connects what you learned in school to real life situations...." Read more
"...way - book is fun to read - it is like "Dune" but for developers - intriguing, you wait for - what gonna happen next? with some light humor...." Read more
"...While the content of the book is quite good and interesting to read, the layout is frustrating." Read more
"I've wanted a book like this for a long time which examines the subject clearly and thoroughly from a modern perspective...a joy to read." Read more
Customers find the book a joy to read. They say the content is interesting and it connects what they learned in school to real life.
"Fabulous book, it connects what you learned in school to real life situations...." Read more
"...Either way - book is fun to read - it is like "Dune" but for developers - intriguing, you wait for - what gonna happen next?..." Read more
"...While the content of the book is quite good and interesting to read, the layout is frustrating." Read more
"...the subject clearly and thoroughly from a modern perspective...a joy to read." Read more
Reviews with images
Excellent read for improving program runtimes at the CPU level
-
Top reviews
Top reviews from the United States
There was a problem filtering reviews right now. Please try again later.
Branch prediction articles were most beneficial to me - many open eyes techniques - thank you! - and it makes you think, again ...
Memory management - at least I got confirmation what is wrong and what is right :).
Either way - book is fun to read - it is like "Dune" but for developers - intriguing, you wait for - what gonna happen next? with some light humor.
I would recommend this book to any level of serious software developers/engineers.
This book deserves 5 stars.
-- this review form 30+ years experience C++ software developer, and counting
By the middle of the first chapter, I was pretty thoroughly disabused of that hubris. Fedor G. Pikus is a real heavyweight in this field. I don't know if he has an advanced degree -- he doesn't list one -- but I would imagine that he is one of those folks who has just been too busy to pursue one. He's got a list of publications and research papers that spans several pages of web search hits.
Mr. Pikus did an incredible job with this book. He explains some counter-intuitive concepts with a straightforward clarity that left me somewhat embarrassed with how little I knew, and how much I just took for granted because somebody just told me to do something in a particular way at some point in my career. And there were some things that I *did* know, but he explained in a way much better than I had seen before.
It's not an easy read. In order to get the most out of this book, you have really go through every example very carefully. Fortunately, the examples use tools that are readily available in the open-source world.
While I still think that choice of algorithm dwarfs all other considerations combined, Mr. Pikus showed that the choice of the most appropriate algorithm is not always obvious, sometimes for very obscure reasons. So, how does one choose? Pikus demonstrated the use of several tools that can help.
Unfortunately for me, I'm working in an environment where the actual target hardware and OS is not yet available, so I have to rely on simulations which might be sub-optimal. But I expect that when I do get to the point in this project that I get to test with the actual target system, that this book will come in handy. It is well organized, and will be a useful reference.
In summary, this is one of the best-written books on this subject that I have seen to date.
Top reviews from other countries
From this perspective, Fedor's book is a valuable and necessary addition to the available C++ book selection. It is a comprehensive volume on many different aspects of performance. Starting with essential questions like "What is performance?", it covers performance benchmarking and profiling, performance tools, and low-level code optimization, concurrency and design for performance. For that reason it provides insight into many different aspects of optimization. Targeted at less-experienced programmers, it always keeps a reasonable pace and explains even the most basic aspects.
I personally consider the chapters about performance profiling and benchmarking as a very valuable addition, since these topics are rarely touched in such a comprehensive way. Unfortunately there were also a couple of letdowns. For instance, I personally felt that advanced topics like lock-free programming were handled too quickly and without much depth. There is very little information beyond the terminology. Also, I was expecting more from the "Design for Performance" chapter. Unfortunately many essential design aspects, as for instance "Separation of Concerns" and the need to design interfaces for performance from the very beginning, are not mentioned at all. For my personal taste, the given advice is too abstract and too few concrete examples are given on how to apply the design advice on real code.
Overall this is a good introduction to the essential performance aspects in software development for aspiring C++ developers.
Reviewed in Germany on November 19, 2022





