معرفی کتاب «Efficient C++ : performance programming techniques» نوشتهٔ Dov Bulka, David Mayhew، منتشرشده توسط نشر Addison-Wesley Professional در سال 1999. این کتاب در فرمت pdf، زبان انگلیسی ارائه شده است. «Efficient C++ : performance programming techniques» در دستهٔ بدون دستهبندی قرار دارد.
Most of the book is similar to Meyers books. The last chapter is great. I don't know of any other book that presents this information, and this is what programmers screw up most when trying to write high performance code. This chapter discusses how to write extremely tight code considering the actual hardware you're running on (a lot of this is generalizable, since a lot of hardware is similar enough.). Things like writing code to avoid cache misses. Code that pipelines well. Replacing conditionals with small non-conditional code (avoid the branch). Context switching performance, etc.. Basically, this section is what gets you to actually think about the system you're writing software for. The real world, practical reality. This topic is a must have, especially if you're writing a game engine or physics engine. Anything that needs to be as fast as possible, or faster than the competition... handling loads of data in real time. I gave the book 3 stars, because I really want a full book on this, not just a short chapter at the end as an afterthought. The authors however do cite 2 other books that they used to write this section, and I'm going to go check them out. As an introduction to hardware-minded performance optimization, this chapter is pretty cool. sample.pdf -1 sterling.com -1 Welcome to Sterling Software -1 Efficient C++ Performance Programming Techniques.pdf 1 Table of Content 2 Copyright 5 Dedication 6 Preface 6 Introduction 8 Roots of Software Inefficiency 8 9 Figure 1. High-level classification of software performance. 9 Figure 2. Refinement of the design performance view. 9 Figure 3. Refinement of the coding performance view. 10 Our Goal 11 Software Efficiency: Does It Matter? 11 Terminology 12 Organization of This Book 13 Chapter 1. The Tracing War Story 15 Our Initial Trace Implementation 16 What Went Wrong 17 Figure 1.1. The performance cost of the Trace object. 18 The Recovery Plan 19 Figure 1.2. Impact of eliminating one string object. 20 Figure 1.3. Impact of conditional creation of the string member. 21 Key Points 21 Chapter 2. Constructors and Destructors 23 Inheritance 23 30 Figure 2.1. The cost of inheritance in this example. 30 Composition 32 Lazy Construction 33 Redundant Construction 35 36 Figure 2.2. Overhead of a silent initialization is negligible in this particular scenario. 36 Figure 2.3. More significant impact of silent initialization. 38 Key Points 39 Chapter 3. Virtual Functions 40 Virtual Function Mechanics 40 Templates and Inheritance 42 Hard Coding 43 Inheritance 43 Templates 44 Key Points 45 Chapter 4. The Return Value Optimization 46 The Mechanics of Return-by-Value 46 The Return Value Optimization 47 48 Figure 4.1. The speed-up of RVO. 48 Computational Constructors 49 Key Points 50 Chapter 5. Temporaries 51 Object Definition 51 Type Mismatch 52 Pass by Value 54 Return by Value 54 Eliminate Temporaries with op=() 56 Key Points 57 Chapter 6. Single-Threaded Memory Pooling 58 Version 0: The Global new() and delete() 58 Version 1: Specialized Rational Memory Manager 59 60 Figure 6.1. A free list of Rational objects. 60 Figure 6.2. Global new() and delete() compared to a Rational memory pool. 63 Version 2: Fixed-Size Object Memory Pool 63 66 Figure 6.3. Adding a template memory pool for generic objects. 66 Version 3: Single-Threaded Variable-Size Memory Manager 66 67 Figure 6.4. Variable-size memory free list. 67 Figure 6.5. A variable-size memory pool is naturally slower than fixed-size. 71 Key Points 72 Chapter 7. Multithreaded Memory Pooling 73 Version 4: Implementation 73 75 Figure 7.1. Comparing multithreaded to single-threaded memory pooling. 75 Version 5: Faster Locking 75 76 Figure 7.2. Multithreaded memory pool using faster locks. 76 Figure 7.3. Comparing the various flavors of memory pooling. 78 Key Points 78 Chapter 8. Inlining Basics 80 What Is Inlining? 80 Method Invocation Costs 83 84 Figure 8.1. Call frame register mapping. 84 Why Inline? 86 Inlining Details 87 Inlining Virtual Methods 87 Performance Gains from Inlining 88 Key Points 89 Chapter 9. Inlining—Performance Considerations 90 Cross-Call Optimization 90 Why Not Inline? 94 Development and Compile-Time Inlining Considerations 96 Profile-Based Inlining 96 98 Table 9.1. The Inlining Decision Matrix 98 Inlining Rules 99 Singletons 99 Trivials 99 Key Points 100 Chapter 10. Inlining Tricks 101 Conditional Inlining 101 Selective Inlining 102 Recursive Inlining 103 Inlining with Static Local Variables 106 Architectural Caveat: Multiple Register Sets 108 Key Points 108 Chapter 11. Standard Template Library 110 Asymptotic Complexity 110 Insertion 110 111 Figure 11.1. Speed of insertion. 111 Figure 11.2. Object insertion speed. 114 Figure 11.3. Comparing object to pointer insertion. 114 Figure 11.4. Comparing list to vector insertion. 115 Figure 11.5. Vector insertion with and without capacity reservation. 115 Figure 11.6. Inserting at the front. 116 Deletion 117 118 Figure 11.7. Comparing list to vector deletion. 118 Figure 11.8. Deleting elements at the front. 118 Traversal 119 119 Figure 11.9. Container traversal speed. 119 Find 120 121 Figure 11.10. Container search speed. 121 Figure 11.11. Comparing generic find() to member find(). 122 Function Objects 122 123 Figure 11.12. Comparing function objects to function pointers. 123 Better than STL? 124 125 Figure 11.13. Comparing STL speed to home-grown code. 125 Key Points 126 Chapter 12. Reference Counting 127 128 128 Figure 12.1. Duplicating resources. 128 Implementation Details 128 129 Figure 12.2. A simple design for a reference-counted Widget class. 129 Figure 12.3. Adding inheritance and smart pointer to the reference-counting design. 129 Figure 12.4. BigInt assignment speed. 136 Figure 12.5. BigInt creation speed. 136 Preexisting Classes 137 137 Figure 12.6. Reference-counting a pre-existing BigInt. 137 Figure 12.7. BigInt creation speed. 140 Concurrent Reference Counting 140 142 Figure 12.8. Multithreaded BigInt assignment speed. 142 Figure 12.9. Multithreaded BigInt creation speed. 143 Key Points 143 Chapter 13. Coding Optimizations 145 Caching 146 Precompute 147 Reduce Flexibility 148 80-20 Rule: Speed Up the Common Path 148 Lazy Evaluation 151 Useless Computations 153 System Architecture 154 Memory Management 154 Library and System Calls 156 Compiler Optimization 157 Key Points 158 Chapter 14. Design Optimizations 159 Design Flexibility 159 Caching 162 Web Server Timestamps 162 Data Expansion 162 The Common Code Trap 163 Efficient Data Structures 164 Lazy Evaluation 165 getpeername() 165 Useless Computations 167 Obsolete Code 168 Key Points 169 Chapter 15. Scalability 170 170 170 Figure 15.1. Single processor architecture. 170 Figure 15.2. Threads are the scheduling entities. 171 The SMP Architecture 172 173 Figure 15.3. The SMP Architecture. 173 Amdahl's Law 174 174 Figure 15.4. Potential speedup is limited. 174 Figure 15.5. A specific design of one Web server. 175 Multithreaded and Synchronization Terminology 175 Break Up a Task into Multiple Subtasks 176 Cache Shared Data 177 Share Nothing 178 Partial Sharing 180 180 Figure 15.6. A single shared resource. 180 Figure 15.7. Breaking up a single shared resource. 180 Lock Granularity 181 False Sharing 183 Thundering Herd 184 Reader/Writer Locks 185 Key Points 186 Chapter 16. System Architecture Dependencies 187 Memory Hierarchies 187 188 Table 16.1. Memory Access Speed 188 Registers: Kings of Memory 188 Disk and Memory Structures 191 Cache Effects 193 Cache Thrash 194 Avoid Branching 195 Prefer Simple Calculations to Small Branches 196 Threading Effects 197 Context Switching 198 Kernel Crossing 200 Threading Choices 201 Key Points 203 Bibliography 204
far Too Many Programmers And Software Designers Consider Efficient C++ To Be An Oxymoron. They Regard C++ As Inherently Slow And Inappropriate For Performance-critical Applications. Consequently, C++ Has Had Little Success Penetrating Domains Such As Networking, Operating System Kernels, Device Drivers, And Others.
efficient C++ Explodes That Myth. Written By Two Authors With First-hand Experience Wringing The Last Ounce Of Performance From Commercial C++ Applications, This Book Demonstrates The Potential Of C++ To Produce Highly Efficient Programs. The Book Reveals Practical, Everyday Object-oriented Design Principles And C++ Coding Techniques That Can Yield Large Performance Improvements. It Points Out Common Pitfalls In Both Design And Code That Generate Hidden Operating Costs.
This Book Focuses On Combining C++'s Power And Flexibility With High Performance And Scalability, Resulting In The Best Of Both Worlds. Specific Topics Include Temporary Objects, Memory Management, Templates, Inheritance, Virtual Functions, Inlining, Reference-counting, Stl, And Much More.
With This Book, You Will Have A Valuable Compendium Of The Best Performance Techniques At Your Fingertips.
electronic Review Of Computer Books - Jack Woehr
conformity To The Purity Of The Conceptual Model Of A Language Is Sufficient For Superficially Minded Programmers, But The Genuine Programming Aesthetic Demands Code That Is Both Attractive And Efficient. efficient C++, By Dov Bulka And David Mayhew, Is About Achieving The Second--efficiency--without Sacrificing The First, If Possible.
If
Std::string S1, S2, S3, S4;
// ...
S1 = S1 + S2 + S3 + S4;
is Object Poetry, Yet This Assignment Must Yield Place In C++ To The More Prosaic
Std::string S1, S2, S3, S4;
// ...
S1 += S2;
S1 += S3;
S1 += S4;
to Avoid Unnecessary Temporary Objects. Some Of These Cycle Devourers The Optimizer Can Handle; Others Arise From The Specification Of The Language Itself. The Compiler Cannot, In The Example Above, Discard The Constructor Semantics Of The Temporaries Called For In The Expression, Merely In The Name Of Optimization.
Each Decade Programmers Seem To Spend Less Time At The Machine Instruction Level. It Seems Nowadays In The Workplace As If Many Programmers Find It Intellectually And Emotionally Challenging To Accommodate Their Idealistic View Of Programming Models With Practical Considerations Such As The Machine Efficiency Of A Given Language Construct.
In efficient C++, Bulka And Mayhew Have A Clear Sighting Along The Trajectory From C++ To Object Expressions To C To Assembly Code To Machine Execution. They Not Only Know The Semantics Of The Language Prescribed By The C++ Standard; They Share With Us Their Insight Into What The Code Generated By The Standard Compiler Will Actually Do At Run Time Across A Wide Range Of Target Architectures.
When You Find Yourself Confronting The Issues Covered In This Book, You'll Be Programming At A Level Where You Will Have To Solve These Issues Your Own Way For Your Particular Circumstances, Despite The Authors' Frequent, Apt Code Examples. The Zen Of efficient C++ Is Bound Up With The Timelessness Of The Proverb That To Discover The Question Is To Find The Answer.
efficient C++ Is A Good Way To Develop A Sense Of What The Compiler Is Doing With Your Code, While Simultaneously Becoming Aware Of The Limitations Of Abstract Programming Models Such As The One Presented By C++.
Far too many programmers and software designers consider efficient C++ to be an oxymoron. They regard C++ as inherently slow and inappropriate for performance critical applications. Consequently, C++ has had little success penetrating domains such as networking, operating system kernels, device drivers, and others. Efficient C++ explodes that myth. Written by two authors with first-hand experience wringing the last ounce of performance from commercial C++ applications, this book demonstrates the potential of C++ to produce highly efficient programs. The book reveals practical, everyday object-oriented design principles and C++ coding techniques that can yield large performance improvements. It points out common pitfalls in both design and code that generate hidden operating costs. This book focuses on combining C++'s power and flexibility with high performance and scalability, resulting in the best of both worlds. Specific topics include temporary objects, memory management, templates, inheritance, virtual functions, inlining, referencecounting, STL, and much more.