Selective Function Precompilation for Faster Template Compilation
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Precompiled header files that include templatized codes consume significant computational resources and time due to inefficient compilation of functions, negating the performance improvements intended by their use.
Innovation Solution
A compiler system that identifies functions to compile based on the number of previous compilations and the time taken, generating precompiled header files only for functions exceeding certain thresholds, thereby optimizing resource usage.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Productivity
If precompiled header files include templatized codes, then code reusability and performance are improved, but compilation time and computational resource consumption increase significantly
Solution Approach 1:
The system changes the parameter of compilation selection from binary (compile all or none) to selective based on instantiation frequency thresholds. By monitoring how often templatized functions are instantiated and comparing against thresholds, the system dynamically determines which functions to precompile, resolving the contradiction between code reusability and compilation time.
Solution Approach 2:
The system introduces feedback mechanisms by tracking instantiation frequencies of templatized functions during compilation. This feedback information is used to adjust compilation decisions, allowing the system to learn from past compilation patterns and optimize future precompilation choices, thereby reducing unnecessary compilation time while maintaining code reusability benefits.
2Productivity
If precompiled header files include templatized codes, then code reusability is improved, but computational resource consumption increases
Solution Approach 1:
The system changes the parameter of compilation selection based on instantiation frequency thresholds. By monitoring how often templatized functions are instantiated and comparing against thresholds, the system dynamically determines which functions to precompile, resolving the contradiction between code reusability and computational resource consumption.
Solution Approach 2:
Instead of compiling all templatized functions (excessive action), the system applies partial action by selectively compiling only those functions that exceed the instantiation frequency threshold. This partial compilation approach maintains code reusability for frequently used functions while avoiding unnecessary computational resource consumption for rarely used functions.
3Speed
If all functions are precompiled, then execution performance is improved, but memory usage and processing power are wasted
Solution Approach 1:
The system applies local quality by differentiating compilation treatment for different functions based on their instantiation frequency. Frequently instantiated functions receive precompilation treatment for optimized execution, while rarely instantiated functions are compiled on-demand. This localized optimization resolves the contradiction between execution performance and resource waste.
Solution Approach 2:
The system changes the parameter of compilation selection based on instantiation frequency thresholds. By monitoring how often templatized functions are instantiated and comparing against thresholds, the system dynamically determines which functions to precompile, resolving the contradiction between code reusability and computational resource consumption.
Data Source
AI summary
Apparatuses, systems, and techniques to identify functions to be compiled in program code by compilers. In at least one embodiment, a processor includes one or more circuits to perform a compiler to identify one or more functions to compile based, at least in part, on a number of times the one or more functions were previously compiled.


