Table of Contents
- 1. Essential Needs
- 2. Problems that exist
- 3. Solution
Briefly, the C++14 Standard's description modification of memory optimization will allow the compiler to introduce a memory allocation optimization strategy similar to that of the tcmalloc, without sticking to the original one that has a new statement that allocates memory for a silly situation. Therefore, it is reasonable to believe that the C + + program compiled by C++14 compiler can improve the performance of the memory allocation. The following text is derived from the documentation provided by the Clang compiler, and I have made a free translation of its main content. The personal feeling is that you no longer need to introduce TCMALLOC libraries to help improve performance, just use c++14 directly.
1 Essential needs
Need to optimize memory allocation and recycling
- The allocation and recycling of memory has become a very important cost for modern systems.
- Differentiate memory allocation optimizations and call optimizations
- A good system performance requires a different allocation strategy for the dynamic behavior of the application, or a different allocation strategy based on the clues provided by the application.
2 Problems that exist
- The current C + + standard may cause
- The allocation policy only considers things that are related to the order of the new/delete statements, ignoring other important information that helps to optimize
- The allocation policy only considers the invocation statement that allocates memory for each new statement, ignoring the optimization of the allocation
3 Solution Solutions
It is recommended that the wording of the standard document be modified so that more accurate focus is given to the intrinsic requirements, allowing some compiler and memory allocators to support the optimized behavior that is embodied, such as Tcmalloc.
- In some cases, the number of calls to the memory allocation function cannot be observed in the program. This allows the implementing person to reduce the number of calls (by avoiding calls or merging calls)
- Avoid calls or merge calls that do not allocate more space than the new statement in the code requires, with the exception of requiring additional memory to fill the gap in order to accommodate memory alignment requirements.
This recommendation does not apply to the class-specific memory allocator
- The proposed standard directly describes the implementation to comply with Data-race free rules, reference data-race free history and Data-race free principle
Author:dean
Created:2015-12-27 Day 16:17
Validate
C++14 a significant optimization of memory allocation performance